-   Programming (
-   -   static linking to c library (

lantern 04-18-2004 02:56 PM

static linking to c library
I'm a bit of a newcomer to linking. Does anybody know how to statically link to the c library and other user-defined libraries on linux? I use Mandrake, and I can't find the libc.a file on my system (nor am I sure what I would do with it). To dynamically link I run:

ld -shared <library object files> -o
ld -L . -dynamic-linker /lib/ \
-o testrun -lc -ltest <object files>

and this works just fine. But I'd like to do some benchmarking with staticly linked executables as well. Any help would be great ...


lone_nut 04-19-2004 08:58 AM

well you just type:
gcc -o foo bar.c -l[i]lib[/lib]

note: the -l is needed and it is not a capital i

note 2: you don't have to link to -lc this is done automaticly

happy hacking

All times are GMT -5. The time now is 04:20 PM.