Kim Oldfield
Presented to Linux Users of Victoria
This talk is a hands on guide for someone who has never compiled a program under linux before, or someone who has never tried to compile a package from source.
Debian packages: gcc, cpp, binutils, libc-dev. C++ programs also require: g++, and libstdc++
RedHat packages: egcs, cpp, binutils, glibc-devel. C++ programs also require: egcs-c++, libstdc++.
gcc is the standard Linux compiler, 2.7.2 is the latest stable version.
egcs is a breakaway development of gcc. This has since been renamed to gcc.
From /usr/doc/gcc/README.Debian.gz in gcc-2.95.2-0pre2:
As of gcc-2.95, optimisation at level 2 (-O2) and higher includes an optimisation which breaks C code that does not adhere to the C standard. Such code occurs in the Linux kernel, and probably other places.
There are a couple of 272 packages for Debian potato (unstable) to get around this - gcc272, gcc++272.
/* hello.c */
#include <stdio.h>
int main(int argc, char *argv[])
{
if (argc > 1)
printf("Greetings %s.\n", argv[1]);
else
printf("Please tell me your name.\n");
return 0;
}
Compile using:
> gcc -Wall -o hello hello.c
Run with:
> ./hello Linus
Greetings Linus.
gcc options
The info pages (info gcc) has much more information about gcc. These are in the gcc-doc package.