title: G++ ARM cross compiling: undefined references
body: <p>I am trying to compile the <a href="http://www.openssd-project.org" rel="nofollow">Jasmine OpenSSD</a> code with arm-none-eabi-g++.
  However, it first failed with the following error message</p>
  
  <pre><code>/usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/bin/ld: cannot find -lstdc++
  </code></pre>
  
  <p>To fix that, I ensured that linking with libstdc++.a was possible. Once I fixed that, it failed with the following errors:</p>
  
  <pre><code>/usr/lib/gcc/arm-none-eabi/4.8.2//libgcc.a(unwind-arm.o): In function `get_eit_entry':
  /build/buildd/gcc-arm-none-eabi-6/build/arm-none-eabi/libgcc/../../../gcc-4.8.2/libgcc/unwind-arm-common.inc:221: undefined reference to `__exidx_end'
  /build/buildd/gcc-arm-none-eabi-6/build/arm-none-eabi/libgcc/../../../gcc-4.8.2/libgcc/unwind-arm-common.inc:221: undefined reference to `__exidx_start'
  /usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/lib/libc.a(lib_a-abort.o): In function `abort':
  /build/buildd/newlib-2.1.0/build/arm-none-eabi/newlib/libc/stdlib/../../../../../newlib/libc/stdlib/abort.c:63: undefined reference to `_exit'
  /usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/lib/libc.a(lib_a-signalr.o): In function `_kill_r':
  /build/buildd/newlib-2.1.0/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/signalr.c:61: undefined reference to `_kill'
  /usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/lib/libc.a(lib_a-signalr.o): In function `_getpid_r':
  /build/buildd/newlib-2.1.0/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/signalr.c:96: undefined reference to `_getpid'
  /usr/lib/gcc/arm-none-eabi/4.8.2/../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
  /build/buildd/newlib-2.1.0/build/arm-none-eabi/newlib/libc/reent/../../../../../newlib/libc/reent/sbrkr.c:58: undefined reference to `_sbrk'
  collect2: error: ld returned 1 exit status
  make: *** [firmware.elf] Error 1
  </code></pre>
  
  <p>Here is the actual step at which it fails:</p>
  
  <pre><code>arm-none-eabi-g++ -static -nostartfiles -ffreestanding -T ld_script -Wl,-O1,-Map=list.txt  ftl.o sata_identify.o sata_cmd.o sata_isr.o sata_main.o sata_table.o initialize.o mem_util.o flash.o flash_wrapper.o misc.o uart.o init.o -o firmware.elf -L"/usr/lib/gcc/arm-none-eabi/4.8.2/" -lgcc
  </code></pre>
  
  <p>Can someone suggest a fix? Also, this works perfectly well if I use arm-none-eabi-gcc instead of arm-none-eabi-g++</p>