https://github.com/agateau/quickcpp
Command-line tool to quickly build and run a single C++ file. Handy for quick experimentations
https://github.com/agateau/quickcpp
Last synced: 6 months ago
JSON representation
Command-line tool to quickly build and run a single C++ file. Handy for quick experimentations
- Host: GitHub
- URL: https://github.com/agateau/quickcpp
- Owner: agateau
- License: apache-2.0
- Created: 2021-07-11T21:12:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-11T21:22:35.000Z (over 4 years ago)
- Last Synced: 2025-06-28T08:59:15.378Z (7 months ago)
- Language: Python
- Size: 25.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# quickcpp
`quickcpp` is a small command-line tool to quickly build and run a single C++ file. Handy for quick experimentations.
## Usage
The simplest usage is `quickcpp `. When called like this, `quickcpp` builds the file (producing a `a.out` file) and runs the result.
```
$ cat examples/helloworld.cpp
#include
int main(int argc, char** argv) {
std::cout << "Hello world!\n";
return 0;
}
$ quickcpp examples/helloworld.cpp
- Building ---------------------
c++ examples/helloworld.cpp -Wall -fPIC -std=c++17 -g
- Running ----------------------
Hello world!
```
### Using other libraries
Want to experiment something with [QtWidgets][]? You can specify any installed pkg-config compliant packages using `-p `:
[QtWidgets]: https://doc.qt.io/qt-5.15/qtwidgets-index.html
```
$ cat examples/qt.cpp
#include
#include
int main(int argc, char** argv) {
QApplication app(argc, argv);
QMainWindow window;
window.setWindowTitle("Hello World");
window.show();
return app.exec();
}
$ quickcpp -p Qt5Widgets examples/qt.cpp
- Building ---------------------
c++ examples/qt.cpp -Wall -fPIC -std=c++17 -g -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/x86_64-linux-gnu/qt5 -lQt5Widgets -lQt5Gui -lQt5Core
- Running ----------------------
```
You should see a window like this one:

Any package listed by `pkg-config --list-all` can be used by `quickcpp`.
### Live reload
`quickcpp` can use [entr](http://entrproject.org/) to automatically rebuild and rerun your file. Just install `entr` and run `quickcpp` with the `-l` flag.
## Installation
The recommended solution is to use [pipx][]:
```
pipx install quickcpp
```
[pipx]: https://github.com/pipxproject/pipx
But you can also install it with `pip`:
```
pip install --user quickcpp
```
## License
Apache 2.0