This is a command line inteface that helps me with my cpp projects. It runs on node js that helps compile all cpp files into an execution file. it can be configured, through a config.json file or through cli arguments. Good luck with c++ lad, hope you survive.
- You will need the latest version of Mingw-w64 which you can get from here, and follow the installation guide.
- The backbone of this cli is Node JS, without it, this cli will not work. here's a link to download node js, download Node JS
- Another thing you'll needm is to NPM. You could say, this allows you to install the cli globally, that way, you can just use cpp-comp in any directory. you don't have to download npm, it comes with node js fam.
There are 2 ways of installing this cli, honestly, it isn't on npm right now, so I guess I'll have to make you do manual labor, sorry :(.
- Manual way:
So, first download the this repo, bynpm install -g .
So at the most basic level, this cli will take all .cpp files that it finds in a source folder, compiles them down to .o files, then the linker will do finish up the process and an execution file will be made. lets compile a basic .cpp project.
to compile, input the following in the cli
cpp-comp
don't worry if you have an empty prject file, cpp-comp will auto-generate a source directory and a main.cpp file
If you really want to know, here's the compilation process (NB: this is a very dumbed down explanation):
- Take all .cpp files, and compile down to .o files
- Take all the .o files and link them to build the .exe file
- Enjoy the .exe you just made
Usually, auto generated main.cpp file will look like this
#include <iostream>
using namespace std;
int main() {
cout << "Hello world" << endl;
return 0;
}
// Auto generated file.
In order to watch files, you can do it one of the folowing ways
- in the CLI:
cpp-comp -w
or
cpp-comp --watch
- in the compile.config.json
{
//...
"watch": true
//...
}