Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-04-2012, 05:29 AM   #1
LQ Newbie
Registered: Dec 2011
Posts: 2

Rep: Reputation: Disabled
Question How do I link to a non-default glibc library?

I have successfully cross-compiled a program on an x86-64 machine. However, when I try to run on my target machine sh4a, I get the following error:
./ioq3ded.sh4a: /lib/ version `GLIBC_2.11' not found (required by ./ioq3ded.sh4a)

The details of the two machines are as follows:
Compiling machine
architecture: x86-64
LIBC version: 2.11

Executing mechine
architecture: sh4a
LIBC version: 2.5

Programming Language is C

Therefore, as a solution, I tried to compile a 2.11 LIBC library on the sh4a machine. However, it failed because the GCC compiler on the sh4a machine was too old, I don't have the authority, nor is there a possibility for upgrading the GCC.
Furthermore, as an alternative solution, I tried to compile a 2.5 LIBC library on the x86-64 so I can link to them during cross-compilation time. However, the ./configure failed because there were missing required objects.
Moreover, I tried to -static compile the program. However, it failed:
As for ioquake3, I tried to statically build it:
/bin/ld: /r/home7/usr/lib/libc.a(dl-tsd.o): TLS local exec code cannot be linked into shared objects
It seems impossible to statically build it with the old version of gcc we have.
I looked up this problem:

Moreover, I downloaded the LIBC 2.5 for x86-64 from the net:[^]

However, I cannot seem to find the right flags for compiling so that it links against MY specific (2.5 version library) rather than the system ones (2.11 version library).

Here comes my question:
* What should be the "make" flags be? considering that the folder where MY (2.5 version library) is:
And, my make is as follows:

Sorry for my lengthy post. I am still working hard on learning how to build in linux. So, if my question sounds naive, please for give me : )

Old 12-08-2012, 12:21 PM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
What you're trying to do is essentially build a cross toolchain. This is never easy. My best suggestion is to be persistent, and recognize that it will take a lot of work and time. There will be loads of dependencies, and a lot of dead-end approaches as you find out what combination of dependencies work together and which do not. Sadly, a cross-native toolchain is possibly the most difficult to build, because so many components' build-tools falsely detect that they are to build for a native architecture.

Having said that, it may work for you to copy the required shared-object libraries from the target host, to the development host. Put them somewhere that is not in conflict with the existing native libraries. Then in your Makefile system, use liberally the '-L' linker option to specify the location of the libraries that belong to the target host. Probably, the path(s) can be added to $(LDFLAGS).

--- rod.
Old 12-10-2012, 05:20 AM   #3
Sergei Steshenko
Senior Member
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Originally Posted by coffeenet View Post
...I don't have the authority, nor is there a possibility for upgrading the GCC. ...
You may not have the authority (i.e. root permission, permission to change something at system level), but you do have a possibility.

One can build 'gcc' (and its dependencies for that matter) running configure with

, so 'gcc' will be installed there.

But, as Rod correctly pointed out, it will be painful. And 'glibc' is not a friendly target to build.


cross-compile, gcc, linux

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
Best way to trace library calls in C on SUSE using glibc 2.9 mrbarritt Programming 1 09-28-2010 07:53 AM
Local Glibc shared library (.so) exploit jayjwa Linux - Security 3 04-09-2010 10:45 AM
Glibc warning concerning use of getaddrinfo() in static library dwhitney67 Programming 3 06-19-2009 01:43 PM
How to tell compiler to not to use GNU library (glibc) P.S.R.K.S.PRASAD Linux - Kernel 1 12-27-2006 02:58 AM
Replacing glibc using linuxthreads for glibc using nptl (native positx thread library CestusGW Linux From Scratch 4 01-20-2005 07:26 AM

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

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