LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   static linking to c library (https://www.linuxquestions.org/questions/programming-9/static-linking-to-c-library-171735/)

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 libtest.so
ld -L . -dynamic-linker /lib/ld-linux.so.2 \
-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 ...

Thanks

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.