Something like:


# build *.c into *.o

gcc -c -o a.o -Iinclpath1 -Iinclpath2 a.c

gcc -c -o b.o -Iinclpath1 -Iinclpath2 b.c


gcc -c -o z.o -Iinclpath1 -Iinclpath2 z.c


# link *.o into with libs libblah.* and libblaz.* located in (path1, path2)

gcc -shared -o a.o b.o ... z.o -Lpath1 -lblah -Lpath2 -lblaz


You can combine the compile and link phases, but I would recommend not doing it (it will recompile everything each time).  Your build is typically more flexible if you have separate compile and links steps.


gcc -shared -o -Iinclpath1 -Iinclpath2 a.c b.c ... z.c -Lpath1 -lblah -Lpath2 -lblaz





From: Dheeraj Joshi M []
Sent: Saturday, August 29, 2009 3:26 AM
Subject: [Swig-user] Linking libraries during run time..




I want to link few libraries in C ..

But my compilation step says

$gcc -c -o my_file.o my_file.c it does create .o file so giving -L option just neglects the option..

so i cant link my library in this command..

How i can link??? is there any alternative command to be used?

Computers are easy to understand than people.