2.5. Linux Tools for generating a running program¶
2.5.1. editor¶
-
pico
Can be used with no previous experience, but absolutely no advanced features which make programming easier.
-
vi
An old stand-by among programmers. It’s separate command and input mode seem strange at first, but very natural and fast once the learning curve is mastered.
-
emacs
Meant to be a little easier to learn than vi and has some extra features like multiple buffers which are better than native vi. The key bindings can be a bit hard to maneuver.
2.5.2. compiler¶
cc is the standard Unix C compiler - use gcc instead.
$ gcc prog.c
Make executable file called a.out. System libraries are automatically linked into the executable.$ gcc prog.c -o myprog
Make executable file called myprog.$ gcc prog.c -c
Make an object file prog.o to later be linked into an executable file.
Other important options to gcc are: -g – put debugging information in the executable; -Wall – more verbose warnings.
Errors reported by the compiler are called compile-time errors or syntax errors.
2.5.3. linker¶
Two ways: ld and gcc. We will generally use gcc as in:
$ gcc file1.o file2.o -o myprog
2.5.4. make¶
Used to make it easy to compile a program. Makes all the calls to gcc for you to save typing and manages dependencies so that the everything that needs to re-compiled gets re-compiled. Especially useful when more than one source code file are required to compile the executable program.
Two examples of how generate to a Makefile will be given later.
2.5.5. debugger¶
gdb is the native debugger that comes with gcc. Some systems also have xgdb. IDEs also have debuggers. More on this later.