title: Cannot find /lib/libc.so.6
body: <p>I'm cross-compiling an application, but linking blows up with an error that it </p>
  
  <blockquote>
    <p>"cannot find /lib/libc.so.6".</p>
  </blockquote>
  
  <p>The libc.so.6 that it should be using is the one that sits at <code>/home/work/worldcom/filesys/lib/libc.so.6</code>. What have I got wrong here?</p>
  
  <pre><code>linking libobj.so
  arm-none-linux-gnueabi-g++ obj1.o obj2.o obj2.o  -o libobj.so -L/home/work/worldcom/filesys/usr -Wl,-O1 -Wl,-z,defs -Wl,--enable-new-dtags -Wl,--sort-common -Wl,--as-needed -Wl,--hash-style=both -L/home/work/worldcom/filesys -L/home/work/worldcom/filesys/lib -L/home/work/worldcom/filesys/usr/lib -lcurl -shared
  /home/lishevita/armv5tel/arm-2009q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /lib/libc.so.6
  /home/lishevita/armv5tel/arm-2009q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find /lib/libc.so.6
  collect2: ld returned 1 exit status&lt;br /&gt;
  make: *** [libobj.so] Error 1&lt;br /&gt;
  </code></pre>
  
  <p>My makefile is handwritten (i.e. not generated by <a href="http://en.wikipedia.org/wiki/GNU_build_system" rel="noreferrer">Autotools</a>). In order to avoid a blanket "your Makefile is broken" here are some details from the makefile that might help clarify.</p>
  
  <pre><code>CROSS_COMPILE = arm-none-linux-gnueabi-  
  SYSROOT = /home/work/worldcom/filesys/  
  DESTDIR = /home/work/worldcom/filesys/  
  
  RELEASE_CXXFLAGS = -Os  
  DEBUG_CXXFLAGS = -O0 -gstabs  
  PKGCONFIG=`env ROOT=/home/work/worldcom/filesys cross-pkg-config glib-2.0 libcurl --cflags`  
  
  CC = $(CROSS_COMPILE)gcc  
  CXX = $(CROSS_COMPILE)g++  
  LD = $(CROSS_COMPILE)ld  
  AR = $(CROSS_COMPILE)ar  
  
  LDFLAGS = -Wl,-O1 -Wl,-z,defs -Wl,--enable-new-dtags -Wl,--sort-common -Wl,--as-needed -Wl,--hash-style=both -L$(SYSROOT) -L$(SYSROOT)lib -L$(SYSROOT)usr -L$(SYSROOT)usr/lib -lcurl  
  
  libobj.so: $(LIBOBJ_OBJS)  
          @echo linking $@  
          $(CXX) $^ -o $@ $(LDFLAGS) -shared $(PKG_LIBS) 
  </code></pre>
  
  <p>Of course there is also a definition and target for the LIBOBJ_OBJS but those are irrelevant to the problem. </p>