Physics and Astronomy |
|
Physics Home | Study here | Our Teaching | Our Research | Our Centres | News | Work here | EMPS |
Back to top
Compiling and debugging under LinuxContentsLinux distributions come with the GNU Compiler Collection (GCC), and the GNU development tools, the same as the Macs. The difference is which front-end you want to use. This being Linux, you have a choice!Traditional setupTraditionally, Unix/Linux programmers use a text editor such as Emacs or nedit to edit their program files and a program called make to handle compilation.Compilation is handled by creating a control file, traditionally called 'Makefile', listing the source files, compiler options and the exact circumstances under which programs should be recompiled. Typing 'make' at the command line then recompiles all the files that have changed since the last compilation thus avoiding recompiling every single file every single time whether it needs it or not. You may also run make from within Emacs or nedit which has the advantage that the editor will warn you about any unsaved changes to your C files. Basically, the makefile is the equivalent of the 'project' in XCode or other Integrated Development Environments (IDEs). We've created a simple example (basically the world's worst "Hello, world" program) for you to download.
Integrated development EnvironmentsIf Emacs/nedit and make are not to your taste and you prefer an IDE consider: Be warned, there is no support for Linux IDEs within the School.Debuggers[ You may wish to come back to this session after you have covered using the debugger in class. ]As mentioned above, Linux and Mac OS X share the same debugger (gdb). On the Mac, gdb has a user-friendly front-end inside XCode. On Linux you can run gdb from inside of Emacs (they were originally written by the same person) but it is probably easier to use one of the available front-ends: Which you use will probably depend on which is installed on your machine. Whichever you chose, learn the basics of seeing the values of variables and setting breakpoints and watchpoints. It's usually a combination of an item from a menu called "View" and right-clicking on a code statement or variable displayed in a window although some front-ends require you to do it within a specific window. |