Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-03-2012, 04:16 AM   #1
LQ Newbie
Registered: Sep 2011
Posts: 14

Rep: Reputation: Disabled
To compile against particular version of library

I want to compile my program against particular version(like than the default library.How to do that?

thanks and regards
Old 02-03-2012, 10:44 PM   #2
Registered: Mar 2011
Location: Surrey B.C. Canada (Metro Vancouver)
Distribution: Slackware
Posts: 183
Blog Entries: 1

Rep: Reputation: 25
Compiling against different libraries

Number One, make a good backup, restore it to test it's integrity.

Now go ahead and try if you have There will be copious problems.
Difficulties between libraries built for different versions will certainly give you a headache.

If you were super keen and happy to track down all the bits I still wouldn't mix versions.

If the information was valuable to you give me a pat on the back (click my rep)
Old 02-03-2012, 11:08 PM   #3
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Caveat: I have not done this myself, but according to two pages I found online (linked at the bottom of this reply), you simply include the specific .so or .a file in the gcc command line. For instance:

gcc -Wall calc.c /usr/lib/libm.a -o calc
Keep in mind, I assume that works with any library you would normally link with using the -l or -L options to gcc. However, because libc is automatically linked, this may not work for it. You may need to do some research to disable ld's automatic inclusion of '-lc' when linking.

The pages I mentioned earlier:
Stack Overflow: How do you link to a specific version of a shared library in GCC
Excerpt from: An Introduction to GCC
Old 02-07-2012, 06:30 AM   #4
LQ Newbie
Registered: Sep 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thanks for your suggestions.

I am actually cross compiling Eglibc for the ARM architecture using the Linaro Tool chain.
I cross compiled Eglibc.When i tried to verify it, by linking an application against the eglibc's, it was taking the default, that was actaully present in the Cross-compiler and not my copy of

As per the caveat of Dark Helmet, it was not working.

So how should i proceed.As per my understanding,in x86,the linker ie ld, reads /etc/ and also the directories specified in the LD_LIBRARY_PATH to take the libraries.
In that way, is there any path or file that needs to be modified?
And any hints on how to disable the automatic inclusion of -lc while loading and link my version of libc.

thanks and regards


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
How to compile against an alternate library version klappnase Linux - General 5 12-07-2011 03:44 PM
library version ust Linux - Software 1 01-07-2008 06:55 AM
library version sha_neb Linux - Software 3 08-01-2007 03:07 AM
library version?? kaz2100 Debian 1 11-11-2006 10:58 AM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 05:20 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:15 AM.

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