Linker “ld: cannot find /lib/″

Having frustrated using Scratchbox to compile my module code for ARM device, I decided to switch to cross-compilation in Desktop for ARM target. I feel scratchbox is one of the most stupidest, difficult to use, good-for-nothing software, which serves nothing better than what cross compiler toolchains can do. And the worst part is, if you do not have admin rights at the host system where scratchbox is installed, then it means, you can not install and use your favourate softwares, like emacs, git!! Stealing your freedom?, definately not a good deal!. Right?

Well, next task was to setup the cross-compilation environment, in my host x86 machine, using appropriate toolchains, with the aid of gcc’s –sysroot option. I managed to write a small script to cross-compile my code using scratchbox-toolchain-arm-linux-cs2010q1-202 cross compiler ( Compilation went through fine, however, while linking my module, linker thowed below error, even though I made sure all paths are properly set,

/opt/compilers/arm-linux-cs2010q1-202/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /lib/ when searching for /lib/
/opt/compilers/arm-linux-cs2010q1-202/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find /lib/

It seems like linker is searching for “/lib/″ instead of plain “″. After scratching head for hours and googling, I figured the cause for this error. The linker script at libc/usr/lib/ has the following grouping,

GROUP ( /lib/ /usr/lib/libpthread_nonshared.a )

And so this is where the /lib/ path is coming from. Modifiying the above line and removing the path information, like below,

GROUP ( libpthread_nonshared.a )

linking just happened perfectly fine! Best part is, the compilation happens much faster now. Also I am able to use all my native sotwares freely. I got my “freedom” back. :)

Post a comment or leave a trackback: Trackback URL.


  • Jason Kridner  On April 28, 2011 at 1:48 pm

    Why not use a non-scratchbox-configured cross-compiler? Consider or downloading a compiler directly from Code Sourcery. Is your system such that you need to use the scratchbox compiler?

    • nayankk  On April 28, 2011 at 1:59 pm

      We should be able to use any cross-compiler, not just the scratchbox-congifured one. I was just trying with scratchbox configured cross-compiler, hence mentioned the same compiler here. 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: