title: How configure xtensa-lx106-elf to compile c++ code for esp8266 using nonos-sdk?
body: <p>I'm having difficulties to compile c++ code with xtensa-lx106-elf.</p>
  
  <p>The manufacture of the chip I'm using (esp8266) provides a sdk (nonos-sdk). 
  One of the libraries in this sdk implements functions to allocate memory in the chip: <em>os_malloc</em>, <em>os_realloc</em>, etc.</p>
  
  <p>When compiling <strong>c</strong> code, everything works fine. When compiling <strong>c++</strong>, object files are generated successfully but I get a lot of error messages from the linker, complaining about undefined references to <em>abort</em>, <em>free</em>, <em>malloc</em> and a very odd one to <em>__gxx_personality_v0</em>.</p>
  
  <p>My make file was created using cmake. Bellow the options that I use with the compiler.</p>
  
  <pre><code>target_include_directories( 
    ${elf_file}
  
    PUBLIC
    src/
    inc/
    /opt/esp-open-sdk/sdk/driver_lib/include/
    /opt/esp-open-sdk/sdk/include/
    )
  
  target_compile_options(
    ${elf_file}
  
    PUBLIC
    -mlongcalls -c -std=c++11 -v
    )
  
  target_link_libraries( 
    ${elf_file}
  
    PUBLIC
  
    -L/opt/esp-open-sdk/sdk/lib
    -L/opt/esp-open-sdk/sdk/ld
    -Teagle.app.v6.ld
  
    -nostdlib
  
    -Wl,--start-group
      -lmain -lhal -lnet80211 -lcrypto -lupgrade -lwpa -llwip -lpp -lphy -v
    -Wl,--end-group
  
    -ldriver
    -lcirom
    -lgcc
    )
  </code></pre>
  
  <p>Compiler errors:</p>
  
  <pre><code>CMakeFiles/MasterSPI-esp8266.elf.dir/src/main.cpp.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
  CMakeFiles/MasterSPI-esp8266.elf.dir/src/spi.cpp.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2.o):(.literal+0x8): undefined reference to `abort'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2.o): In function `execute_cfa_program':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2.c:1212: undefined reference to `abort'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2.o): In function `read_encoded_value_with_base':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-pe.h:252: undefined reference to `abort'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2.o): In function `execute_stack_op':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2.c:905: undefined reference to `abort'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2.o): In function `uw_update_context_1':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2.c:1420: undefined reference to `abort'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2.o):/home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2.c:1560: more undefined references to `abort' follow
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o):(.literal+0x20): undefined reference to `malloc'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o):(.literal+0x24): undefined reference to `free'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o): In function `size_of_encoded_value':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-pe.h:88: undefined reference to `abort'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o): In function `read_encoded_value_with_base':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-pe.h:257: undefined reference to `abort'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o): In function `base_from_object':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:256: undefined reference to `abort'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o): In function `start_fde_sort':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:409: undefined reference to `malloc'
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:412: undefined reference to `malloc'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o): In function `end_fde_sort':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:575: undefined reference to `abort'
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:590: undefined reference to `free'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o): In function `__register_frame':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:118: undefined reference to `malloc'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o): In function `__register_frame_table':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:156: undefined reference to `malloc'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o): In function `__deregister_frame_info_bases':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:200: undefined reference to `free'
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:216: undefined reference to `abort'
  /opt/esp-open-sdk/sdk/lib/libgcc.a(unwind-dw2-fde.o): In function `__deregister_frame':
  /home/wjg/Repo/esp-open-sdk-20170622/crosstool-NG/.build/src/gcc-4.8.5/libgcc/unwind-dw2-fde.c:231: undefined reference to `free'
  </code></pre>
  
  <p>Something that catch my attention is that it seems the linker is trying to find many files in the path: "<em>/home/wjg/Repo/</em>" and I can confirm it doesn't exist in my computer. Can't understand this behavior.</p>
  
  <hr>
  
  <p>Tools info:</p>
  
  <p><strong>OS</strong>: Ubuntu 16.04LTS</p>
  
  <p><strong>Compiler</strong>: xtensa-lx106-elf-g++ (crosstool-NG crosstool-ng-1.22.0-60-g37b07f6) 4.8.5</p>
  
  <p><strong>CMake</strong>: cmake version 3.12.0-rc3</p>
  
  <p><strong>nonos-sdk</strong>: 2.2.1</p>