I’ve recently installed Ubuntu 11.10 and along with it the CodeBlocks IDE and I am aware that I have gcc and the std libraries by default.
My questions are:
- Do you you have any tips for a new C++ programmer on Ubuntu?
- Any libraries I should get from the start?
- A really good IDE I’m missing? (YMMV but I prefer to work in IDE’s)
- Any programming boons or traps I should be aware of from the start?
You don’t need an IDE to code in C or C++ on Ubuntu. You can use a good editor (like
emacs, which you can configure to suit your needs.).Some few tips for a newbie:
-Wall -Wextraand perhaps even with-Werror -pedantic-errorsOrder of arguments to the compiler (
gccorg++) are really important; I recommend:-Wall,-gto get debug info,-O,-fltoetc, or-cto avoid linking , …)-Iinclude-dir and-Ddefined-symbol (or-Hto understand which headers get included) etc..hello.corworld.ccelse.o, add them after the source files-Llibrary-dir (and probably-rdynamicif your program uses plugins with dlopen(3) ….)-lfoo -lbarfrom higher-level libraries likelibfoo.soto lower-level libraries.-o yourexec.Always correct your source code till you got no warning at all. Trust the compiler’s warnings and error messages.
Learn how to use
makeand to write simpleMakefile-s; see this example.there are other builders, e.g. http://omake.metaprl.org/ etc
-gflag to have the compiler produce debugging information; only when you have debugged your program, ask the compiler to optimize (e.g. with-O1or-O2), especially before benchmarking.gdbsvnorgit(even for a homework assignment). In 2015 I recommend git oversvnNB
The advices above are not specific to Ubuntu 11.10, they could apply to other Linux distributions and other Ubuntu versions.