LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-18-2004, 02:56 PM   #1
lantern
Member
 
Registered: Sep 2003
Distribution: Debian, Slackware
Posts: 39

Rep: Reputation: 15
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
 
Old 04-19-2004, 08:58 AM   #2
lone_nut
Member
 
Registered: Dec 2003
Location: Denmark
Distribution: Mandrake
Posts: 179

Rep: Reputation: 30
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM
linking own library bobby2k3 Programming 2 10-20-2003 10:36 AM
Help Linking Library!! Please!! Musikolo Linux - Software 1 07-24-2003 03:16 PM
linking library simonissa Linux - Software 2 05-21-2003 09:41 AM
Static/dynamic linking ugenn Linux - Software 0 12-15-2002 11:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration