I am used to compiling a single main.cpp file with warnings using this command on terminal:
g++ -Wall -Wextra std=c++14 main.cpp -o main
Let's say I have 2 more files (file_1.cpp, file_2.cpp) that will link with main.cpp. I saw this command that compiles such files:
g++ -I path -c file_1.cpp -o file_1.o
g++ -I path -c file_2.cpp -o file_2.o
where path
is the path directory of the header files. And then I compile the main.cpp and link it to the previous objects with:
g++ -I path -o main main.cpp file_1.o file_2.o
If I want to include the warnings -Wall -Wextra
and standard -std=c++14
, where do I write such options? On the final compilation of main.cpp, in each compilation of every file, somewhere else, or don't need to at all?