Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 5 months ago.
Problems linking against xDot library
I just tried the following steps:
mbed import http://mbed.org/teams/MultiTech/code/Dot-Examples/ cd Dot-Examples/ mbed add http://mbed.org/teams/MultiTech/code/libxDot-mbed5/ mbed compile -m xdot_l151cc -t GCC_ARM
And I'm getting a link error:
Scan: FEATURE_STORAGE Scan: env Scan: mbed Link: Dot-Examples ./BUILD/xdot_l151cc/GCC_ARM/examples/src/dot_util.o: In function `join_network()': dot_util.cpp:(.text._Z12join_networkv+0x3e): undefined reference to `mDot::getReturnCodeString[abi:cxx11](long const&)' ./BUILD/xdot_l151cc/GCC_ARM/examples/src/dot_util.o: In function `sleep_wake_rtc_or_interrupt(bool)': dot_util.cpp:(.text._Z27sleep_wake_rtc_or_interruptb+0x5e): undefined reference to `mDot::pinName2Str[abi:cxx11](PinName)' ./BUILD/xdot_l151cc/GCC_ARM/examples/src/dot_util.o: In function `send_data(std::vector<unsigned char, std::allocator<unsigned char> >)': dot_util.cpp:(.text._Z9send_dataSt6vectorIhSaIhEE+0x42): undefined reference to `mDot::getReturnCodeString[abi:cxx11](long const&)' [snip]
Is this supposed to work? Compilation succeeds on the online compiler.
Thanks!
Question relating to:
1 Answer
6 years, 5 months ago.
Apparently libxDot was compiled with an older version of C++. Details about the problem here: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
I was able to work around this by compiling Dot-Examples with the following macro
-D_GLIBCXX_USE_CXX11_ABI=0
This is the profile.json that I used:
{ "GCC_ARM": { "common": ["-c", "-Wall", "-Wextra", "-Wno-unused-parameter", "-Wno-missing-field-initializers", "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", "-ffunction-sections", "-fdata-sections", "-funsigned-char", "-MMD", "-fno-delete-null-pointer-checks", "-fomit-frame-pointer", "-Os"], "asm": ["-x", "assembler-with-cpp"], "c": ["-std=gnu99"], "cxx": ["-std=c++98", "-fno-rtti", "-Wvla", "-D_GLIBCXX_USE_CXX11_ABI=0"], "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit"] } }
and compiling as...
mbed compile -m xdot_l151cc -t GCC_ARM --profile profile.json
I had this same problem, and this solution worked. I also needed to add -Wl,- -allow-multiple-definition to the ld (linker) options to suppress errors about duplicate definitions of Mbed functions. (Remove the space in - -allow if you copy/paste this; the correct version doesn't render properly in this forum.) MultiTech really needs to fix their library.
posted by 05 Feb 2018Assigned to
6 years, 5 months ago.This means that the question has been accepted and is being worked on.