Android demo building fails
Options
Hi,
I'm trying to build demo_basics example from the Android-NDK SDK. For some reason, I'll get the following errors:
Any ideas what might be the problem?
I'm trying to build demo_basics example from the Android-NDK SDK. For some reason, I'll get the following errors:
C:\Temp\Photon-AndroidNDK-Sdk_v4-1-3-2\Demos\demo_basics\android>c:\SDK\AndroidSdk\ndk-bundle\ndk-build APP_PLATFORM=android-8
Android NDK: WARNING: APP_PLATFORM android-24 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
[arm64-v8a] Gdbserver : [aarch64-linux-android-4.9] libs/arm64-v8a/gdbserver
[arm64-v8a] Gdbsetup : libs/arm64-v8a/gdb.setup
[x86_64] Gdbserver : [x86_64-4.9] libs/x86_64/gdbserver
[x86_64] Gdbsetup : libs/x86_64/gdb.setup
[mips64] Gdbserver : [mips64el-linux-android-4.9] libs/mips64/gdbserver
[mips64] Gdbsetup : libs/mips64/gdb.setup
[armeabi-v7a] Gdbserver : [arm-linux-androideabi-4.9] libs/armeabi-v7a/gdbserver
[armeabi-v7a] Gdbsetup : libs/armeabi-v7a/gdb.setup
[armeabi] Gdbserver : [arm-linux-androideabi-4.9] libs/armeabi/gdbserver
[armeabi] Gdbsetup : libs/armeabi/gdb.setup
[x86] Gdbserver : [x86-4.9] libs/x86/gdbserver
[x86] Gdbsetup : libs/x86/gdb.setup
[mips] Gdbserver : [mipsel-linux-android-4.9] libs/mips/gdbserver
[mips] Gdbsetup : libs/mips/gdb.setup
[arm64-v8a] SharedLibrary : libdemobasics.so
jni/../../../../LoadBalancing-cpp/lib/loadbalancing-cpp-prebuilt/../../../Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a.a(PeerBase.o): In function `std::__1::lock_guard::lock_guard(std::__1::mutex&)':
D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:85: undefined reference to `std::__1::mutex::lock()'
jni/../../../../LoadBalancing-cpp/lib/loadbalancing-cpp-prebuilt/../../../Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a.a(PeerBase.o): In function `std::__1::lock_guard::~lock_guard()':
D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:90: undefined reference to `std::__1::mutex::unlock()'
jni/../../../../LoadBalancing-cpp/lib/loadbalancing-cpp-prebuilt/../../../Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a.a(PeerBase.o): In function `std::__1::lock_guard::lock_guard(std::__1::mutex&)':
D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:85: undefined reference to `std::__1::mutex::lock()'
jni/../../../../LoadBalancing-cpp/lib/loadbalancing-cpp-prebuilt/../../../Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a.a(PeerBase.o): In function `std::__1::lock_guard::~lock_guard()':
D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:90: undefined reference to `std::__1::mutex::unlock()'
jni/../../../../LoadBalancing-cpp/lib/loadbalancing-cpp-prebuilt/../../../Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a.a(PeerBase.o): In function `__static_initialization_and_destruction_0':
D:\a\Android\Photon-cpp/jni/../src/Internal/PeerBase.cpp:36: undefined reference to `std::__1::mutex::~mutex()'
D:\a\Android\Photon-cpp/jni/../src/Internal/PeerBase.cpp:36: undefined reference to `std::__1::mutex::~mutex()'
collect2.exe: error: ld returned 1 exit status
make: *** [obj/local/arm64-v8a/libdemobasics.so] Error 1
Any ideas what might be the problem?
0
Comments
-
Hi @Scam.
It seem that when building the demo project the linker can't find definitions for parts of the standard library. Have you changed anything in the project before trying to build? Which NDK version do you use and which NDK toolchain?0 -
My NDK is 12.1.2977051 (and it is installed via Android Studio 2.2 Preview 6 and I'm using Windows 10, if that matters).
My ultimate goal is to include Photon to my cmake project (now that Android Studio finally supports it), but now I was just testing how to build the demos. So I downloaded the SDK, extracted it, went to the demo_basics and read from the build.txt how to build the demo. The result can be read above. I haven't changed anything in the project.
Previously I have built all my C++ stuff from the command line via ndk-build and I haven't experienced any problems like this.0 -
I don't know where you got this long number from, but I was talking about the official NDK release version number: https://developer.android.com/ndk/downloads/revision_history.html
You need to use 10d or newer. Older versions may not work properly.
But as you are using such a recent Android Studio version I doubt that your NDK is outdated.
I have just tested the instructions from the readme file and they work just fine for me. I could not reproduce your errors at all.
I have tested with NDK r10e btw.0 -
The long number comes from Android Studio's SDK Manager application. I assume it's version 12 (since it was downloaded via SDK Manager, and the first number is 12).
Anyway, I tried to build the demo with standalone NDK r11c and r11b and they both produce the same error. Weird.
My only option seems to be a clean install of Android Studio, SDK and NDK? Hopefully it works then.0 -
I managed to get demo to be built with NDK-r10e. I just had to first delete the NDK which was installed via SDK Manager.
However, it seems that Photon cannot be used with NDK-r12b. I tried it again, this time I downloaded stand-alone zip for NDK-r12b and tried to build the demo with it. Same errors are produced.0 -
Hi @Scam.
Thank you for your help. I could now reproduce this by testing with r12b.
Please update to 4.1.3.3. This release is identical to 4.1.3.2 except for being built with r12b instead of r10e.0 -
Big thanks for quick response!0
-
HI,
I just tried 4.1.3.3 with r12b and android-24 on my project and received something similar to this issue, is there something wrong with my setting?
/android-ndk/build//../sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:85: error: undefined reference to 'std::__ndk1::mutex::lock()'
/android-ndk/build//../sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:90: error: undefined reference to 'std::__ndk1::mutex::unlock()'
/android-ndk/build//../sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:85: error: undefined reference to 'std::__ndk1::mutex::lock()'
/android-ndk/build//../sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:90: error: undefined reference to 'std::__ndk1::mutex::unlock()'
jni/../src/Internal/PeerBase.cpp:936: error: undefined reference to 'std::__ndk1::mutex::~mutex()'
collect2: error: ld returned 1 exit status
0 -
Hi @charlesso.
Please make sure that you use C++_static as standard lib with 4.1.3.3.
Note: starting with 4.1.4.0 the requirement will change to gnustl_static.0 -
Hi,
Any plans on when 4.1.4.0 is coming out?
We have other 3rd party that require to use gnustl_static. It will be a great help not to use c++ _static. Our current plan is to back to use r10e.
Thanks0 -
Hi @charlesso.
There is no release date yet, but I am pretty confident it will get released later this month.Our current plan is to back to use r10e.
Please be aware that you also need to go back to 4.1.3.2 for this to work.1 -
We've got the very same issue. We use Cocso2d-x and can not use C++_Static, but updated everything to the new 4.1.3.3 which works fine on iOS but not Android.
Since you said they are identical (just built with different NDK versions), could anybody of you guys provide the 4.1.3.2 version for Android (and maybe also iOS, so I'm using the same everywhere) in the meantime.
I've seen that you sometimes share older version via Dropbox Links.
Unfortunately, There's no "previous version" section in the download base.0 -
I'm having the exact same issue with UE4. Building against NDK 12b.
I need to have this fixed asap...
Edit: I reverted to another version I had lying around, 4.0.4.1, which works perfectly fine with the same NDK and everything... Would still like to use the newest version though!0 -
Hey @Kaiserludi ,
Could you upload 4.1.3.2 (for cocos2d-x and Unreal) for us until this gets fixed with 4.1.4.0?
This would be awesome.0 -
4.1.4.0 should be released in the next couple of days.
Until then feel free to use 4.1.3.2 for compatibility to Cocos and Unreal on Android, but keep in mind that you need to use an older NDK for it to work:
https://dl.dropboxusercontent.com/u/4296291/Photon-AndroidNDK-Sdk_v4-1-3-2.zip0 -
Thanks, but it doesn't help.
It's still the same error with this version and Android NDK 10e:D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:85: error: undefined reference to 'std::__1::mutex::lock()' D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:90: error: undefined reference to 'std::__1::mutex::unlock()' D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:85: error: undefined reference to 'std::__1::mutex::lock()' D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:90: error: undefined reference to 'std::__1::mutex::unlock()'
0 -
@Kaiserludi What do I need to do to be able to build for Android again?
The NDK version doesn't matter to use, we can use 10e, 12 or 13.
But we can't change the C++_static0 -
Hi @framusrock.
For 4.1.3.2 you would need to use 10d or 10e.
4.1.3.3 requires r12 or up and the same will be the case for 4.1.4.0.
If you still get these errors with 4.1.3.2, then please make sure that you have those 2 settings in your Application.mk:APP_STL := gnustl_static APP_CPPFLAGS := -std=c++11
0 -
My Android-NDK RELEASE.TXT says this: "r10e (64-bit)"
This is my Application.mk:APP_STL := gnustl_static APP_ABI := armeabi APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char APP_LDFLAGS := -latomic ifeq ($(NDK_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release endif
I deleted the obj, lib and bin folders in my android project folders to ensure a full rebuild
Then I downloaded 4.1.3.2 from your dropbox again (to be sure), deleted the old folders first and then copied in the new ones.
Then I tried building the cocos2d-x project with this command:cocos run -p android -m debug --android-studio
And again:[armeabi] StaticLibrary : libbullet.a [armeabi] StaticLibrary : libcpufeatures.a [armeabi] StaticLibrary : libcocos2dandroid.a [armeabi] SharedLibrary : libcocos2dcpp.so D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:85: error: undefined reference to 'std::__1::mutex::lock()' D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:90: error: undefined reference to 'std::__1::mutex::unlock()' D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:85: error: undefined reference to 'std::__1::mutex::lock()' D:/android-ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__mutex_base:90: error: undefined reference to 'std::__1::mutex::unlock()' jni/../src/Internal/PeerBase.cpp:936: error: undefined reference to 'std::__1::mutex::~mutex()' collect2: error: ld returned 1 exit status make: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1 make: Leaving directory `/Users/Max/Documents/XcodeWorkspace/TowerDuelWorkspace/TowerDuel/proj.android-studio/app' Error running command, return code: 2.
Here's the first few line of my build log. It seems like it's using Toolchain 4.9, maybe it should be 4.8?
Or maybe you find something else here.Building mode: debug Using Android Studio project : /Users/Max/Documents/XcodeWorkspace/TowerDuelWorkspace/TowerDuel/proj.android-studio Android platform not specified, searching a default one... running: '/Users/Max/Library/Android/sdk/tools/android update project -t android-10 -p /Users/Max/Documents/XcodeWorkspace/TowerDuelWorkspace/TowerDuel/proj.android-studio/app' Updated project.properties Updated local.properties Updated file /Users/Max/Documents/XcodeWorkspace/TowerDuelWorkspace/TowerDuel/proj.android-studio/app/proguard-project.txt Building native... NDK build mode: debug NDK_TOOLCHAIN_VERSION: 4.9 running: '/Users/Max/Library/Android/android-ndk/ndk-build -C /Users/Max/Documents/XcodeWorkspace/TowerDuelWorkspace/TowerDuel/proj.android-studio/app -j8 NDK_MODULE_PATH=/Users/Max/Documents/XcodeWorkspace/TowerDuelWorkspace/TowerDuel/proj.android-studio/../cocos2d:/Users/Max/Documents/XcodeWorkspace/TowerDuelWorkspace/TowerDuel/proj.android-studio/../cocos2d/cocos:/Users/Max/Documents/XcodeWorkspace/TowerDuelWorkspace/TowerDuel/proj.android-studio/../cocos2d/external NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1'
0 -
Hi @framusrock.
Sorry, but I have just realized that I somehow mixed up at which version we have changed that setting with at which version we have changed the supported NDK version.
Please use https://dl.dropboxusercontent.com/u/4296291/Photon-AndroidNDK-Sdk_v4-1-3-0.zip instead.
Still r10e should be used.
Sorry for the inconvenience.0 -
Hi @Kaiserludi
THANK YOU. That was a nightmare.
Could you also provide us with the iOS version of 4.1.3.0?
Just to be sure they are 100% compatible.0 -
Hi @Scam, @charlesso, @Hugo_Peters and @framusrock.
We have just released 4.1.3.4 in our download area, which has been built against NDK r12b and GNU STL.0