New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to link C++ standard library to espressif platform build #503

Closed
martianmartin opened this Issue Feb 9, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@martianmartin

martianmartin commented Feb 9, 2016

I am unable to link against stdc++ library using the espressfi platform. I am able to do this in arduino IDE by adding -lstdc++ to platforms.txt. I have tried adding "stdc++" and "supc++" to the LIBS array in the espressif.py builder but this does not seem to have any effect. Any assistance appreciated.

Thank you

@valeros

This comment has been minimized.

Member

valeros commented Feb 9, 2016

Hi @martianmartin! Did you try build_flags option in your platformio.ini?

platform = espressif
framework = arduino
board = esp01
build_flags = -lstdc++ -lsupc++
@martianmartin

This comment has been minimized.

martianmartin commented Feb 9, 2016

Hi @valeros, yes I tried using the build flags. When I do that, in addition to the 'undefined reference' errors I also get 'multiple definition' errors and 'dangerous reallocation: call0: call target out of range" errors.

The multiple definition errors make me think that part of the library is being left out, so re-including the entire thing may cause overlap?

Let me know what other information I can provide you to clarify the problem. I didn't want to paste the whole compiler error printout because it's very long but I can if that would help.

@martianmartin

This comment has been minimized.

martianmartin commented Feb 9, 2016

As an experiment I removed the lines which perform map operations, which allows it to compile successfully. Then, adding back:
build_flags = -lstdc++ lsupc++
results in the error:

.pioenvs\esp12e\libFrameworkArduino.a(abi.o): In function operator delete(void*)': abi.cpp:(.text._ZdlPv+0x4): multiple definition ofoperator delete(void_)'
c:/users/marzipan/appdata/roaming/spb_16.6/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib\libstdc++.a(del_op.o):d:\ivan\projects\arduinoesp\toolchain\dl\gcc-xtensa\build-2\xtensa-lx106-elf\libstdc++-v3\libsupc++/../../../../libstdc++-v3/libsupc++/del_op.cc:45: first defined here
collect2.exe: error: ld returned 1 exit status
scons: *_* [.pioenvs\esp12e\firmware.elf] Error 1

@valeros

This comment has been minimized.

Member

valeros commented Feb 9, 2016

Thanks, @martianmartin. I've reproduced this error, it's due to library linking order. Could you please try this version of PlatformIO with your project?
pip install https://github.com/platformio/platformio/archive/feature/cpp-libs-issue-503.zip

@martianmartin

This comment has been minimized.

martianmartin commented Feb 10, 2016

Yes, that worked, thank you so much. I am sincerely impressed with your responsiveness.

Do you mind explaining how the library linking order was wrong and how you fixed it?

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment