Compiling C++ |
C++ programs can be compiled directly using g++ or (better yet) compiled using a makefile. A single-file program can be compiled and linked by typing
g++ myProg.cpp
where myProg.cpp is the name of the program. This will produce a file called a.out that can be run by typing
./a.out
For more control over the name of the executable file type
g++ myProg.cpp -o execName
where execName is the name you'd like to give to the executable file. We will see later how we can create a makefile that will allow us to automate the compilation and linking of C++ programs.
Compiling C++ |