Advanced Linux Programming

Compiling with GCC

GNU Compiler Collection

Suppose two files (main.cpp and add.cpp) has to be compiled and linked together to produce result

for compiling single

% gcc -c main.c -o main

or g++ -c add.cpp (-c option tells g++ compiler the program to an object file only)

linking object file:

g++ -o add main.o add.o

Last updated