The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Linux Linking Issue: undefined reference to symbol '_ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4'

2019-03-18 16:14:19

I'm trying to compile our projects' linux version with the Photon SDK but I'm getting the following error :

/usr/bin/ld: ../sdks/photon-linux/Common-cpp/libCommonDebug64.a(CustomTypeBase.o): undefined reference to symbol '_ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4'  
//usr/lib/x86_64-linux-gnu/ error adding symbols: DSO missing from command line  
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm building with CLang and Cmake, below are the flags I'm using :

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -DLINUX -fsigned-char -fexceptions")  
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")

Any help would be greatly appreciated !


2019-03-18 16:21:37

According to this, it might be because I'm building using clang and libc++ but the photon SDK is built with GCC and libstdc++.
Is there anyway to get photon build with CLang / libc++ as well ?

2019-03-18 18:29:24

Hi @MadZaf.

I agree that this is very likely the reason for the error.

Unfortunately currently we only support g++ on Linux, but not clang.

2019-03-18 20:37:26

Hi @Kaiserludi

So apparently adding -Wl,--copy-dt-needed-entries to the Linker flags solved it.

So it might just be an ordering issue.
I'll do some more testing tomorrow. I hope that's it because I cannot build the project with g++ unfortunately.
Thank you for your answer.

2019-07-23 06:05:55


Thank You for sharing that "magic" linker flag that worked for me on Android as well. I tried to link libc++ libraries under Android Studio with NDK 16b. It gave me a lot of strange link errors like "undefined reference to 'std::ios_base::Init::Init()'" and many undefined references, where they are well defined in source code and it compiles on Windows and iOS.
I added -Wl,--copy-dt-needed-entries then it complied on Android. But when I removed that option, got same errors as before, but tried to change photon libraries link order, and changed it 3 times. After third change, when I reverted libraries order in CMakeLists.txt as it was from beginning, it somehow started to build even without "-Wl,--copy-dt-needed-entries". It's strange, but now it can build successfully. I'll try it on another PC, maybe that linker option is needed after all to make it link after Photon upgrade. And it's not dirty build cache, I tried to clean it and rebuild many times. Maybe it's a case when just "clean" doesn't work...

2019-07-23 13:38:59

Hi @User228.

When you get the error on Android, that typically indicates a standard library mismatch between libc++ (the clang standard library) and libstdc++ (the GCC standard library) as in your app gets built against one of those two, but links against a variant of the Photon libs that has been built against the other one.
Make sure to link against the Photon libs with the "_libc++" postfix in their names when using the clang standard lib in your app, and against the ones without it, when using the GCC standard lib.

Please see for more information.

2019-07-29 10:30:55

Thank You!
I think it was Android Studio build cache issue, coz on another PC I deleted app/build folder and it compiled fine without "-Wl,--copy-dt-needed-entries".

Back to top