I am writing some OpenGL code, and my links to libraries in /usr/lib is getting quite unwieldly:
g++ Application.cpp -lglfw -lGL -lGLEW
I don't want to hunt around/can't remember the exact names of the libraries EVERY TIME i want to complile something, so in my project folder I have a file called linkingsNeeded.txt. That file contains that command and nothing else. Is there a way to save the list of linkings so I can just type
g++ Application.cpp
And not have to deal with manually linking? Say, in the #include section of the CPP file?
Learn to use some build automation tool such as GNU make or ninja.
You'll then edit your Makefile
(with make); this could be inspirational and just build your program by typing make
. Most source code editors (like GNU emacs) or IDEs can be easily configured to run make
with a single keypress.
Of course you want to invoke GCC as g++ -Wall -Wextra -g
since you want all warnings and debug info (for the GDB debugger).
Read also How to debug small programs and more about C++, perhaps even the n3337 quasi C++11 standard.