3

I am working in an embedded environment. I have a cross compiler for ARM architecture with eglibc as it's primary library (ie. the default libc coming along with the tool chain). Now I want some of the applications to link with uClibc. So I compiled uClibc with that tool-chain. Now while trying to compile and link the application with uClibc, there is an error. It is getting linked with the default library of the tool-chain. I think its is possible to have two different libcs on the same machine (eg. libc, uClibc).

I searched on the net and came with the following

  1. Multiple glibc libraries on a single host

    As it suggested, I did the following

    $arm-unknown-linux-gnueabi-gcc -c test.c -o TEST
    
    $arm-linux-gnueabi-gcc TEST -o dynamic_test_with_new_opts -Wl,rpath=/home/user/UCLIBC/uClibc-0.9.32.1/INSTALL-DIR/usr/arm-linux-uclibc/lib -Wl,-dynamic-linker=/home/user/UCLIBC/uClibc-0.9.32.1/INSTALL-DIR/usr/arm-linux-uclibc/lib/ld-uClibc.so.0 
    

    In this case, it is getting linked with the default libc.so.6 of eglibc

  2. How to link to a different libc file?

    As the above link suggested, I even tried the following:

    $arm-unknown-linux-gnueabi-gcc -Xlinker -rpath=/home/user/UCLIBC/uClibc-0.9.32.1/INSTALL-DIR/usr/arm-linux-uclibc/lib -Xlinker -I/home/user/UCLIBC/uClibc-0.9.32.1/INSTALL-DIR/usr/arm-linux-uclibc/lib/ld-uClibc-0.9.32.1.so test.c -o  dynamic_test_with_linker_options 
    

    In this case too, it is getting linked with the default libc.so.6 of eglibc

Where am I going wrong? I am really stuck in this. Can someone please shed some light?

Community
  • 1
  • 1

1 Answers1

2

You need to rebuild the compiler to do that, I think. The compiler needs to be configured differently to use uClibc.

ams
  • 24,923
  • 4
  • 54
  • 75
  • Would you clarify for the sake of completeness how one can tell to compiler/linker where to look for libraries **by default**? Any link? I'm using [musl-cross](https://github.com/GregorR/musl-cross) but can't figure out how to use something else but `/lib` as default. What options shall I pass while building gcc? – mlt May 23 '15 at 18:12
  • You can mess with the specs file, but that's a topic for another question. This question is about one compiler targetting both Glibc and uClibc. – ams May 26 '15 at 09:52