title: libstdc++.so: error adding symbols: File in wrong format
body: <p>I'm trying to build my own library. It worked on x86 linux so I wanna build for MIPS Linux (Little endian.)</p>
  
  <p>I'm using <a href="http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/" rel="nofollow">sourcery codebench</a> in Mento Graphics and <a href="http://buildroot.uclibc.org/" rel="nofollow">buildroot</a> and CMake.</p>
  
  <p>I configured <strong>build_all.sh</strong> like below.</p>
  
  <pre><code>#!/bin/bash -ev
  export TARGETROOT="/usr/mipsel-buildroot-linux-gnu/sysroot"
  
  mkdir -p mips_build
  cd mips_build
  
  cmake  -DCMAKE_SYSTEM_NAME="Linux" \
      -DCMAKE_C_COMPILER="${CROSS_COMPILE}gcc" \
      -DCMAKE_CXX_COMPILER="${CROSS_COMPILE}g++" \
      -DCMAKE_AR="${CROSS_COMPILE}ar" \
      -DCMAKE_C_FLAGS="-EL -c -g  -O2 -fPIC --sysroot=$TARGETROOT "  \
      -DCMAKE_CXX_FLAGS="-EL  -c -g  -O2 -fPIC --sysroot=$TARGETROOT " \
      ../
  
  make
  
  cd .. 
  </code></pre>
  
  <p>Where <strong>$CROSS_COMPILE</strong>=/home/vagrant/bd1/mips-2014.05/bin/mips-linux-gnu-</p>
  
  <p>And <strong>CMakeFiles.txt</strong> is like below. </p>
  
  <pre><code>make_minimum_required (VERSION 2.6)
  
  set(EMSG_INCLUDE_DIR  ${CMAKE_CURRENT_SOURCE_DIR}/../../src/eagle_msg/include )
  set(EMSG_LIB_DIR  ${CMAKE_CURRENT_SOURCE_DIR}/../../lib )
  
  set (PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
  set (PROJECT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
  set (PROJECT_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
  
  
  set(LIBRARIES  
      libemsg.a 
      libzmq.a  
      libprotobuf.a
      libprotobuf-c.a
      libpthread.a
      libstdc++.a
       )
  
  #For controller : Client 
  SET(EXECUTABLE test_controller)
  project (${EXECUTABLE})
  include_directories(
          ${PROJECT_INCLUDE_DIR}
          ${EMSG_INCLUDE_DIR}
          $ENV{TARGETROOT}/usr/include
  )
  
  link_directories( 
      ${PROJECT_LIB_DIR} 
      ${EMSG_LIB_DIR}
      $ENV{TARGETROOT}/usr/lib
  
  )
  
  set(SRCS 
      test_controller.cpp
  )
  add_executable( ${EXECUTABLE}  ${SRCS})
  target_link_libraries( ${EXECUTABLE} ${LIBRARIES} )
  </code></pre>
  
  <p>Then it makes the error like below. </p>
  
  <pre><code>[ 40%] Built target emsg
  Linking CXX executable ../../../bin/test_controller
  /usr/mipsel-buildroot-linux-gnu/sysroot/usr/lib/libstdc++.so: error adding symbols: File in wrong format
  collect2: error: ld returned 1 exit status
  make[2]: *** [../bin/test_controller] Error 1
  make[1]: *** [test/emsg_test/CMakeFiles/test_controller.dir/all] Error 2
  </code></pre>
  
  <p>So I checked the format of libstdc++.so. Then it's ELF 32-bit LSB shared object, MIPS, MIPS32. That's the right version. Then what can I do to solve? </p>
  
  <pre><code>/usr/mipsel-buildroot-linux-gnu/sysroot# file /usr/mipsel-buildroot-linux-gnu/sysroot/usr/lib/libstdc++.* 
  /usr/mipsel-buildroot-linux-gnu/sysroot/usr/lib/libstdc++.a:         current ar archive
  /usr/mipsel-buildroot-linux-gnu/sysroot/usr/lib/libstdc++.so:        symbolic link to `libstdc++.so.6.0.19'
  /usr/mipsel-buildroot-linux-gnu/sysroot/usr/lib/libstdc++.so.6:      symbolic link to `libstdc++.so.6.0.19'
  /usr/mipsel-buildroot-linux-gnu/sysroot/usr/lib/libstdc++.so.6.0.19: ELF 32-bit LSB shared object, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, with unknown capability 0xf41 = 0x756e6700, not stripped
  </code></pre>
  
  <h1><strong>New information</strong></h1>
  
  <p>It seems to be the problem of buildroot. I checked the sysroot value of mips-linux-gnu-gcc. </p>
  
  <p>This is the result before installing buildroot. </p>
  
  <pre><code>$ mips-linux-gnu-gcc --print-sysroot
  /home/vagrant/bd1/mips-2014.05/bin/../mips-linux-gnu/libc
  </code></pre>
  
  <p>This is the result after installing buildroot. </p>
  
  <pre><code>$ mips-linux-gnu-gcc --print-sysroot
  /usr/usr/mipsel-buildroot-linux-gnu/sysroot/soft-float/el
  </code></pre>
  
  <p>I also found the <a href="http://lists.busybox.net/pipermail/buildroot/2013-April/070690.html" rel="nofollow">post</a> about similar problem. But it's old issue. </p>