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:
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 -Wextra
and perhaps even with -Werror -pedantic-errors
Order of arguments to the compiler (gcc
or g++
) are really important; I recommend:
-Wall
, -g
to get debug info, -O
, -flto
etc, or -c
to avoid linking , ...)-I
include-dir and -D
defined-symbol (or -H
to understand which headers get included) etc..hello.c
or world.cc
else.o
, add them after the source files-L
library-dir (and probably -rdynamic
if your program uses plugins with dlopen(3) ....)-lfoo -lbar
from higher-level libraries like libfoo.so
to 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 make
and to write simple Makefile
-s; see this example.
there are other builders, e.g. http://omake.metaprl.org/ etc
-g
flag to have the compiler produce debugging information; only when you have debugged your program, ask the compiler to optimize (e.g. with -O1
or -O2
), especially before benchmarking.gdb
svn
or git
(even for a homework assignment). In 2015 I recommend git over svn
The advices above are not specific to Ubuntu 11.10, they could apply to other Linux distributions and other Ubuntu versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With