title: Debug app segmentation fault? Compiler's fault?
body: <p>I am currently compiling Android Linaro build 11.11 (staging-panda) for pandaboard.</p>
  
  <p>In the build process, Android compiles some tools with the host gcc compiler. On my Linux Mint 12 (Ubuntu-11.10 based), I have gcc-4.6 installed by default.</p>
  
  <p>I built Android, everything runs fine, pandaboard booted, but then starting any application will lead to segmentation fault (signal 11 in logcat). </p>
  
  <p>I then learned that Linaro built this release with gcc-4.5, not 4.6 version. I installed it using apt-get. I removed out/ directory and rebuild Android entirely.</p>
  
  <p>The compilation runs fine, but the linker insults me:</p>
  
  <pre><code>g++-4.5 -Wl,-rpath-link=out/target/product/pandaboard/obj/lib -Wl,-rpath,\$ORIGIN/../lib -Lout/host/linux-x86/obj/lib   -Wl,--no-undefined   -m32          out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o     -Wl,--whole-archive   -Wl,--no-whole-archive  out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/libhost.a   -o out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp 
  g++-4.5 -Wl,-rpath-link=out/target/product/pandaboard/obj/lib -Wl,-rpath,\$ORIGIN/../lib -Lout/host/linux-x86/obj/lib   -Wl,--no-undefined   -m32          out/host/linux-x86/obj/EXECUTABLES/mkbootfs_intermediates/mkbootfs.o     -Wl,--whole-archive   -Wl,--no-whole-archive     -o out/host/linux-x86/obj/EXECUTABLES/mkbootfs_intermediates/mkbootfs 
  /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libstdc++.so when searching for -lstdc++
  /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libstdc++.a when searching for -lstdc++
  /usr/bin/ld: cannot find -lstdc++
  /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libgcc_s.so when searching for -lgcc_s
  /usr/bin/ld: cannot find -lgcc_s
  /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libgcc.a when searching for -lgcc
  /usr/bin/ld: cannot find -lgcc
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>The linker grabs the 64bit libraries of gcc-4.5, although it probably for 32bit version. So far, here are the things I tried, without success:</p>
  
  <ol>
  <li>re-do the package installation following <a href="http://source.android.com/source/initializing.html" rel="nofollow">these instructions</a></li>
  <li>sudo ldconfig</li>
  <li>reboot my machine</li>
  <li>I looked into removing gcc-4.6 to get only gcc-4.5 on my machine.
  But synaptic showed so many dependencies needed to be uninstalled,
  that I didn't make that step :)</li>
  </ol>
  
  <p>Finally I've been told to install gcc-4.5-multilib and g++-4.5-multilib. It worked, and the build got further. I start the panda, still the apps (eg com.android.launcher) fails to launch. I know this is an assumption, but I think that this segfault is somehow linked to the compiler.</p>
  
  <p>My questions are simple:</p>
  
  <ol>
  <li>Is com.android.launcher cross-compiled or compiled with host 32bit
  compiler? What keyword should I look for to find the associated command in the build log?</li>
  <li>How can I debug this segmentation fault? In particular, I am looking
  for starting com.android.launcher with the "am" command.</li>
  <li>Will strace provide valuable information for this issue?</li>
  </ol>
  
  <p>Thanks heaps.</p>