Is there a good ‘how-to’ or ‘getting started’ guide for getting started using g++ and gdb?
Some background. Decent programmer, but so far I have done everything on Windows in Visual Studio.
I have a little experience using terminal to compile files (not much beyond a .h and 1 or 2 .cpp). But nothing beyond that.
Anyone know of a good primer on on how to get started coding on Linux?
Read some good books, notably Advanced Linux Programming and Advanced Unix Programming. Read also the advanced bash scripting guide and other documentation from Linux Documentation Project
Obviously, install some Linux distribution on your laptop (not in some VM, but on real disk partitions). If you have a debian like distribution, run
aptitude build-dep gcc-4.6 gediton it to get a lot of interesting developers packages.Learn some command line skills. Learn to use the
mancommand; after installingmanpagesandmanpages-devpackages, typeman man(use the space bar to “scroll text”, theqkey to quit). Read also the intro(2) man page. When you forgot how to use a command likecptrycp --help.Use a version control system like git, even for one person tiny projects.
Backup your files.
Read several relevant Wikipedia pages on Linux, kernels, syscalls, free software, X11, Posix, Unix
Try hard to use the command line. For instance, try to do everything on the command line for a week or more. Avoid using your desktop, and possibly your mouse. Learn to use
emacs.Read about builder programs like GNU make
Retrieve several free software from their source code (e.g. from sourceforge or freecode or github) and practice building and compiling them. Study their source code
Basic tips to start (if a command is not found, you need to install the package providing it) in command line (in a terminal).
run
emacs; there is a tutorial menu; practice it for half an hour.edit a
helloworld.cprogram (with amaincalling somehellofunction)compile it with
gcc -g -Wall helloworld.c -o helloworld; improve your code till no warnings are given. Always pass-Walltogccorg++to get almost all warnings.run it with
./helloworlddebug it with
gdb ./helloworld, thenhelpcommandb maincommand to add a breakpoint inmainand likewise for yourhellofunction.gdbusingrbtto get a backtracepto print some variablecto continue the execution of the debugged program.write a tiny
Makefileto be able to build yourhelloworldprogram usingmakelearn how to call
make(withM-x compile) andgdb(withM-x gdb) from inside EmacsLearn more about valgrind (to detect most memory leaks). Perhaps consider using Boehm’s GC in some of your applications.