Getting compile errors on Cocos2dx 3.17.2 + Photon-AndroidNDK-Sdk_v4-1-6-0
Options
As the title suggests, I am getting these errors while building on Android version.
What should I do ? Please help!! Is older version (v4-1-6-0) of sdk still recommended ?
jni/../src/EventData.cpp:94: error: undefined reference to 'std::ios_base::Init::~Init()'
/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
jni/../src/OperationRequest.cpp:114: error: undefined reference to 'std::ios_base::Init::~Init()'
/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
jni/../src/OperationResponse.cpp:123: error: undefined reference to 'std::ios_base::Init::~Init()'
/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
jni/../src/PhotonPeer.cpp:852: error: undefined reference to 'std::ios_base::Init::~Init()'
/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/mutex:139: error: undefined reference to 'std::__throw_system_error(int)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
What should I do ? Please help!! Is older version (v4-1-6-0) of sdk still recommended ?
FAILED: : && /weapons/Android/android-ndk-r19c/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi16 --gcc-toolchain=/weapons/Android/android-ndk-r19c/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/weapons/Android/android-ndk-r19c/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mfpu=vfpv3-d16 -fno-addrsig -march=armv7-a -mthumb -mfpu=neon -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++ -frtti -fexceptions -fsigned-char -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libphoton_loadbalancing.so -o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libphoton_loadbalancing.so Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/AuthenticationValues.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/MutablePlayer.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/Player.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/RoomOptions.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/Client.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/LobbyStatsRequest.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/MutableRoom.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/RaiseEventOptions.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/WebFlags.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/FriendInfo.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/LobbyStatsResponse.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/Peer.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/Room.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/AuthenticationValuesSecretSetter.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/PlayerFactory.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/PlayerPropertiesCacher.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/RoomPropertiesCacher.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/MutablePlayerFactory.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/PlayerMovementInformant.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/PlayerPropertiesUpdateInformant.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/Utils.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/MutableRoomFactory.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/PlayerMutableRoomPointerSetter.cpp.o Photon-AndroidNDK-Sdk_v4-1-6-0/CMakeFiles/photon_loadbalancing.dir/LoadBalancing-cpp/src/internal/RoomFactory.cpp.o ../../../../../../Photon-AndroidNDK-Sdk_v4-1-6-0/Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi-v7a_libc++.a ../../../../../../Photon-AndroidNDK-Sdk_v4-1-6-0/Common-cpp/lib/common-cpp-prebuilt/libcommon-cpp-static_debug_android_armeabi-v7a_libc++.a -latomic -lm && :/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
jni/../src/EventData.cpp:94: error: undefined reference to 'std::ios_base::Init::~Init()'
/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
jni/../src/OperationRequest.cpp:114: error: undefined reference to 'std::ios_base::Init::~Init()'
/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
jni/../src/OperationResponse.cpp:123: error: undefined reference to 'std::ios_base::Init::~Init()'
/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
jni/../src/PhotonPeer.cpp:852: error: undefined reference to 'std::ios_base::Init::~Init()'
/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/mutex:139: error: undefined reference to 'std::__throw_system_error(int)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
0
Comments
-
Hi @jeevs.
Currently you link your app against libstdc++ (the GCC standard lib), but at the same time you link it against the versions of the photon libs that have been built against libc++ (the clang standard lib).
Those 2 standard libs are binary incompatible to each other and your app and all 3rd-party libs that it links against must agree on using the same standard lib.
Hence you either need to link your app against libc++ as well or you need to use the Photon libs that have been built gainst libstd++ (the one that don't have a '_libc++ postfix in their file names')
Please also see these other posts of mine for further information on this topic:
https://forum.photonengine.com/discussion/comment/46415#Comment_46415
https://forum.photonengine.com/discussion/comment/42718/#Comment_42718Is older version (v4-1-6-0) of sdk still recommended ?0 -
Hi @Kaiserludi Thanks for the reply.
I checked the links you shared but in my case my build type is cmake.
In Cocos2dx 3.17.2 default build type is cmake.
I found I have linked '_libc++' already like this in 'CMakeLists.txt' of sdk folder.IMPORTED_LOCATION "${PHOTON_ROOT_PATH}/Common-cpp/lib/common-cpp-prebuilt/libcommon-cpp-static_${PHOTON_BUILD_TYPE}_android_${ANDROID_ABI}_libc++.a"
Should I make some changes in my gradle?
I do have this in my build.gradle:cmake { targets 'MyGame' arguments "-DCMAKE_FIND_ROOT_PATH=", "-DANDROID_STL=c++_static", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE" cppFlags "-frtti -fexceptions -fsigned-char" }
Still I got same errors as above in the post.
For iOS in Xcode I am getting different errors:ld: warning: directory not found for option '-L/my_project_folder_path/proj.ios_mac/../Photon-iOS-Sdk_v4-1-6-0Common-cpp/lib' ld: library not found for -lCommon-cpp_Debug_iphoneos clang: error: linker command failed with exit code 1 (use -v to see invocation)
How do I solve all these ?0 -
Hi @jeevs.
I have reviewed our release-history files and discovered that there was a bug in 4.1.6.0 that prevented the _libc++ builds from actually being built against libc++. Despite their names they still got build against libstdc++. This got fixed in 4.1.8.1.
Hence despite what I wrote in my previous post, the solution is to update to a newer version of the SDK.
Please download the latest release 4.1.15.2.
Regarding your Xcode errors:
This looks like the paths are not correct. Xcode can't find '-L/my_project_folder_path/proj.ios_mac/../Photon-iOS-Sdk_v4-1-6-0Common-cpp/lib'.
'Photon-iOS-Sdk_v4-1-6-0Common-cpp' looks like it is missing a '/' between 'Photon-iOS-Sdk_v4-1-6-0' and 'Common-cpp'.0