Error compiling Android NDK
The whole answer can be found below.
Try Our
Documentation
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.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Error compiling Android NDK
juaxix
2016-07-28 17:36:42
Hello guys, I'm trying to compile the last version of the example LoadBalancing for Android NDK. I tried with Visual Studio 2010 and 2015 with VisualGDB installed, and also via cygwin + ndk-build, I don't know how to fix these errors:
NDK in cygwin :
$ /cygdrive/e/UDK/nvpack/android-ndk-r10b/ndk-build
Android NDK: ERROR:jni/Android.mk:photon-cpp-static-prebuilt: LOCAL_SRC_FILES points to a missing file Android NDK: Check that jni/../../Photon-cpp/obj/local/armeabi-v7a/libphoton-cpp-static.a exists or that its path is correct/cygdrive/e/UDK/nvpack/android-ndk-r10b/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting . Alto.
VisualStudio2010: Configured with the java and android sdks, and the ndk paths, everything set, even the project properties, in release configuration...
Error 13 error MSB3073: The command ""W:\CodingSoftware\VisualGDB\VisualGDB.exe" /build "E:\PhotonCloud\SDK\android\LoadBalancing-cpp\AndroidLoadBalancing-cpp.vcxproj" "/solution:E:\PhotonCloud\SDK\android\LoadBalancing-cpp\AndroidLoadBalancing-cpp.sln" "/config:Release" "/platform:Win32"" exited with code 1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets 38 6 AndroidLoadBalancing-cpp
Error 8 error : jni/Android.mk:photon-cpp-static-prebuilt: LOCAL_SRC_FILES points to a missing file E:\PhotonCloud\SDK\android\LoadBalancing-cpp\Android NDK AndroidLoadBalancing-cpp
Error 10 error : Command-line action failed E:\PhotonCloud\SDK\android\LoadBalancing-cpp\VisualGDB AndroidLoadBalancing-cpp
Error 9 error : Android NDK: Aborting . Stop. E:\UDK\nvpack\android-ndk-r10b\build\core\prebuilt-library.mk 45 1 AndroidLoadBalancing-cpp
Message 6 Could not find schema information for the attribute 'Condition'. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets 60 18 Miscellaneous Files
Error 7 [Clang IntelliSense] Error: 'sys/time.h' file not found e:\photoncloud\sdk\android\common-cpp\inc\defines.h 79 12
is there anywhere a guide to compile this project properly?
I was able to compile the Windows version of LoadBalancing with Visual Studio 2015, but this is giving me headaches, so,
Thanks!.
Comments
Kaiserludi
2016-07-29 15:45:01
Hi @juaxix.
This is likely caused by the fact that you are using NDK r10b.
Please update to r12b and download the latest Photon Client SDK (4.1.3.3).
4.1.3.2, which is what you probably work with right now, was the last release that required the NDK version to be either r10d or r10e.
Sorry man, but it wont compile 4.1.3.3 with NDK r12b, just tested. What am i doing wrong?
VS Config:
VGBD Config:
Error:
Warning 4 warning : Your Android NDK contains a bug that prevents it from running 32-bit executables on 64-bit systems. G:\ShivaProjects\PhotonCloud\Plugins\com.xixgames.photoncloudapi\Libs\Photon-AndroidNDK-Sdk_v4-1-3-3\LoadBalancing-cpp\VisualGDB AndroidLoadBalancing-cpp
Warning 5 warning : See this page for instructions how to fix: http://visualgdb.com/KB/?ProblemID=host64 G:\ShivaProjects\PhotonCloud\Plugins\com.xixgames.photoncloudapi\Libs\Photon-AndroidNDK-Sdk_v4-1-3-3\LoadBalancing-cpp\VisualGDB AndroidLoadBalancing-cpp
Error 6 error MSB3073: The command ""W:\CodingSoftware\VisualGDB\VisualGDB.exe" /clean "G:\ShivaProjects\PhotonCloud\Plugins\com.xixgames.photoncloudapi\Libs\Photon-AndroidNDK-Sdk_v4-1-3-3\LoadBalancing-cpp\AndroidLoadBalancing-cpp.vcxproj" "/solution:G:\ShivaProjects\PhotonCloud\Plugins\com.xixgames.photoncloudapi\Libs\Photon-AndroidNDK-Sdk_v4-1-3-3\LoadBalancing-cpp\AndroidLoadBalancing-cpp.sln" "/config:Release" "/platform:Win32"" exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets 33 6 AndroidLoadBalancing-cpp
Error 1 error : jni/Android.mk:photon-cpp-static-prebuilt: LOCAL_SRC_FILES points to a missing file G:\ShivaProjects\PhotonCloud\Plugins\com.xixgames.photoncloudapi\Libs\Photon-AndroidNDK-Sdk_v4-1-3-3\LoadBalancing-cpp\Android NDK AndroidLoadBalancing-cpp
Error 3 error : Command-line action failed G:\ShivaProjects\PhotonCloud\Plugins\com.xixgames.photoncloudapi\Libs\Photon-AndroidNDK-Sdk_v4-1-3-3\LoadBalancing-cpp\VisualGDB AndroidLoadBalancing-cpp
Error 2 error : Android NDK: Aborting . Stop. G:\UDK\nvpack\android-ndk-r10b\build\core\prebuilt-library.mk AndroidLoadBalancing-cpp
I would prefer to compile using a command line than VS2010.
In this case, can you provide the commands to do it please?
This is what i'm doing:
cd Libs\Photon-AndroidNDK-Sdk_v4-1-3-3\LoadBalancing-cpp
E:\UDK\nvpack\android-ndk-r12b\ndk-build.cmd NDK_APPLICATION_MK=jni\Application.mk
And this is the result:
Android NDK: ERROR:jni/Android.mk:photon-cpp-static-prebuilt: LOCAL_SRC_FILES points to a missing file
Android NDK: Check that jni/../../Photon-cpp/obj/local/arm64-v8a/libphoton-cpp-static.a exists or that its path is correct
E:/UDK/nvpack/android-ndk-r12b/build//../build/core/prebuilt-library.mk:45: ***
Android NDK: Aborting . Stop.
Thanks for your time
(edited)
(edited)
(edited)
ERROR!:
G:\ShivaProjects\PhotonCloud\Plugins\com.xixgames.photoncloudapi\Libs\Photon-And
roidNDK-Sdk_v4-1-3-3>E:\UDK\nvpack\android-ndk-r12b\ndk-build.cmd NDK_APPLICATIO
N_MK=LoadBalancing-cpp/jni/Application.mk NDK_PROJECT_PATH=./LoadBalancing-cpp
Android NDK: ERROR:LoadBalancing-cpp/jni/Android.mk:photon-cpp-static-prebuilt:
LOCAL_SRC_FILES points to a missing file
Android NDK: Check that LoadBalancing-cpp/jni/../../Photon-cpp/obj/local/arm64-v
8a/libphoton-cpp-static.a exists or that its path is correct
E:/UDK/nvpack/android-ndk-r12b/build//../build/core/prebuilt-library.mk:45: ***
Android NDK: Aborting . Stop.
Please help @Kaiserludi
no success yet, i tried this:
- in Application.mk i set the APP_ABI := armeabi-v7a
- then i copied all the .a from Photon-AndroidNDK-Sdk_v4-1-3-3\Photon-cpp\lib\photon-cpp-prebuilt to a folder in the same jni folder (there is an error in the mk files because there is no OBJ files for Photon-cpp)
3)so i can set in Android.mk:
LOCAL_SRC_FILES := libs/libphoton-cpp-static_release_android_$(TARGET_ARCH_ABI).a - then i call from a cygwin shell the command to build
/cygdrive/g/ShivaProjects/PhotonCloud/Plugins/com.xixgames.photoncloudapi/Libs/P
hoton-AndroidNDK-Sdk_v4-1-3-3/LoadBalancing-cpp/jni
$ /cygdrive/e/UDK/nvpack/android-ndk-r12b/ndk-build.cmd NDK_PROJECT_DIR=./ NDK_
APPLICATION_MK=Application.mk
I got a "Access Denied", why?
cloudapi/Libs/Photon-AndroidNDK-Sdk_v4-1-3-3/LoadBalancing-cpp/jni
$ /cygdrive/e/UDK/nvpack/android-ndk-r12b/ndk-build.cmd NDK_PROJECT_DIR=./ NDK_
APPLICATION_MK=Application.mk
[armeabi-v7a] "Compile++ thumb": "loadbalancing-cpp-static <= AuthenticationValu
es.cpp"
process_begin: CreateProcess(NULL, E:/UDK/nvpack/android-ndk-r12b/build//../tool
chains/arm-linux-androideabi-4.9/prebuilt/windows /bin/arm-linux-androideabi-g++
-MMD -MP -MF G:/ShivaProjects/PhotonCloud/Plugins/com.xixgames.photoncloudapi/L
ibs/Photon-AndroidNDK-Sdk_v4-1-3-3/LoadBalancing-cpp/obj/local/armeabi-v7a/objs/
loadbalancing-cpp-static//src/AuthenticationValues.o.d -fpic -ffunction-sectio
ns -funwind-tables -fstack-protector-strong -no-canonical-prefixes -g -march=arm
v7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fno-exceptions -fno-rtti -mthumb -Os -D
NDEBUG -I.. -IE:/UDK/nvpack/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc
/libcxx/include -IE:/UDK/nvpack/android-ndk-r12b/build//../sources/cxx-stl/llv
m-libc/../../android/support/include -IE:/UDK/nvpack/android-ndk-r12b/build//.
./sources/cxx-stl/llvm-libcabi/libcxxabi/include -IE:/UDK/nvpack/android-ndk-r
12b/build//../sources/cxx-stl/llvm-libcabi/libcxxabi/include -IE:/UDK/nvpack/a
ndroid-ndk-r12b/build//../sources/android/support/include -IG:/ShivaProjects/Pho
tonCloud/Plugins/com.xixgames.photoncloudapi/Libs/Photon-AndroidNDK-Sdk_v4-1-3-3
/LoadBalancing-cpp/jni -DANDROID -Wa,--noexecstack -Wformat -Werror=format-secur
ity -std=c++11 -fno-strict-aliasing -D_EG_ANDROID_PLATFORM -frtti -isystem E:/UD
K/nvpack/android-ndk-r12b/build//../platforms/android-9/arch-arm/usr/include -c
G:/ShivaProjects/PhotonCloud/Plugins/com.xixgames.photoncloudapi/Libs/Photon-And
roidNDK-Sdk_v4-1-3-3/LoadBalancing-cpp/jni/../src/AuthenticationValues.cpp -o G:
/ShivaProjects/PhotonCloud/Plugins/com.xixgames.photoncloudapi/Libs/Photon-Andro
idNDK-Sdk_v4-1-3-3/LoadBalancing-cpp/obj/local/armeabi-v7a/objs/loadbalancing-cp
p-static//src/AuthenticationValues.o, ...) failed.
make (e=5): Acceso denegado.
make: *** [G:/ShivaProjects/PhotonCloud/Plugins/com.xixgames.photoncloudapi/Libs
/Photon-AndroidNDK-Sdk_v4-1-3-3/LoadBalancing-cpp/obj/local/armeabi-v7a/objs/loa
dbalancing-cpp-static/__/src/AuthenticationValues.o] Error 5
(edited)
(edited)
(edited)
(edited)
(edited)
(edited)
Another thing i have tried is to change the line 20 in the Android.mk (Photon-AndroidNDK-Sdk-4-1-3-3/LoadBalancing/jni/Android.mk):
LOCAL_SRC_FILES := ../../Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_$(TARGET_ARCH_ABI).a
so, they actually point to the prebuild libs.
Result:
C:\Users\Usuario\Downloads\Photon-AndroidNDK-Sdk_v4-1-3-3\LoadBalancing-cpp>e:\U
DK\nvpack\android-ndk-r12b\ndk-build.cmd jni\Application.mk all
make: Nothing to be done for `jni\Application.mk'.
[arm64-v8a] "Compile++ ": "loadbalancing-cpp-static <= AuthenticationValues
.cpp"
process_begin: CreateProcess(NULL, e:/UDK/nvpack/android-ndk-r12b/build//../tool
chains/aarch64-linux-android-4.9/prebuilt/windows /bin/aarch64-linux-android-g++
-MMD -MP -MF ./obj/local/arm64-v8a/objs/loadbalancing-cpp-static//src/Authent
icationValues.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector-st
rong -no-canonical-prefixes -g -fno-exceptions -fno-rtti -O2 -DNDEBUG -I.. -Ie:/
UDK/nvpack/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/libcxx/include
-Ie:/UDK/nvpack/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/../../an
droid/support/include -Ie:/UDK/nvpack/android-ndk-r12b/build//../sources/cxx-stl
/llvm-libcabi/libcxxabi/include -Ie:/UDK/nvpack/android-ndk-r12b/build//../sou
rces/android/support/include -Ijni -DANDROID -Wa,--noexecstack -Wformat -Werror=
format-security -std=c11 -fno-strict-aliasing -D_EG_ANDROID_PLATFORM -frtti -i
system e:/UDK/nvpack/android-ndk-r12b/build//../platforms/android-21/arch-arm64/
usr/include -c jni/../src/AuthenticationValues.cpp -o ./obj/local/arm64-v8a/objs
/loadbalancing-cpp-static//src/AuthenticationValues.o, ...) failed.
make (e=5): Acceso denegado.
make: *** [obj/local/arm64-v8a/objs/loadbalancing-cpp-static/__/src/Authenticati
onValues.o] Error 5
C:\Users\Usuario\Downloads\Photon-AndroidNDK-Sdk_v4-1-3-3\LoadBalancing-cpp>e:\U
DK\nvpack\android-ndk-r12b\ndk-build.cmd jni\Application.mk all
Ok , I was able to compile it using OSX and changing the line of the Android.mk:
LOCAL_SRC_FILES := ../../Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_release_android_$(TARGET_ARCH_ABI).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)../../../Photon-cpp/inc
Result:
LoadBalancing-cpp juaxix$ /Users/juaxix/Downloads/Android/android-ndk-r12b/build/ndk-build NDK_APPLICATION_MK=jni/Application.mk
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= AuthenticationValues.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= Client.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= FriendInfo.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= AuthenticationValuesSecretSetter.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= MutablePlayerFactory.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= MutableRoomFactory.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= PlayerFactory.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= PlayerMovementInformant.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= PlayerMutableRoomPointerSetter.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= PlayerPropertiesCacher.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= PlayerPropertiesUpdateInformant.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= RoomFactory.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= RoomPropertiesCacher.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= Utils.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= LobbyStatsRequest.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= LobbyStatsResponse.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= MutablePlayer.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= MutableRoom.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= Peer.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= Player.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= RaiseEventOptions.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= Room.cpp
[armeabi-v7a] Compile++ thumb: loadbalancing-cpp-static <= RoomOptions.cpp
[armeabi-v7a] StaticLibrary : libloadbalancing-cpp-static.a
cp obj/local/arm64-v8a/libloadbalancing-cpp-static.a lib/loadbalancing-cpp-prebuilt/libloadbalancing-cpp-static_release_android_arm64-v8a.a
cp obj/local/x86_64/libloadbalancing-cpp-static.a lib/loadbalancing-cpp-prebuilt/libloadbalancing-cpp-static_release_android_x86_64.a
cp obj/local/mips64/libloadbalancing-cpp-static.a lib/loadbalancing-cpp-prebuilt/libloadbalancing-cpp-static_release_android_mips64.a
cp obj/local/armeabi-v7a/libloadbalancing-cpp-static.a lib/loadbalancing-cpp-prebuilt/libloadbalancing-cpp-static_release_android_armeabi-v7a.a
cp obj/local/armeabi/libloadbalancing-cpp-static.a lib/loadbalancing-cpp-prebuilt/libloadbalancing-cpp-static_release_android_armeabi.a
cp obj/local/x86/libloadbalancing-cpp-static.a lib/loadbalancing-cpp-prebuilt/libloadbalancing-cpp-static_release_android_x86.a
cp obj/local/mips/libloadbalancing-cpp-static.a lib/loadbalancing-cpp-prebuilt/libloadbalancing-cpp-static_release_android_mips.a
Kaiserludi
2016-08-05 14:36:42
Hi @juaxix.
The "access denied" error might come from unzipping the downloaded folder with Windows itself, which blocks all unzipped files from a downloaded zip-archive, so that you need to manually unblock them. This can be prevented by using a 3rd party program to unzip the archive, for example 7zip.
I can reproduce the obj folder issue when trying to build the LoadBalancing-cpp solution. We will fix this for the next release
However it is not necessary at all to rebuild LoadBalaning-cpp yourself, when you do not modify its source. You can just use the prebuilt libraries that ship with the SDK.
Note that LoadBalancing-cpp is not a demo or example project, but part of the Photon Client libraries and can normally just be used as is. For demo projects on how to use the libraries please look inside the "Demos" folder.
@Kaiserludi wrote:
Hi @juaxix.
The "access denied" error might come from unzipping the downloaded folder with Windows itself, which blocks all unzipped files from a downloaded zip-archive, so that you need to manually unblock them. This can be prevented by using a 3rd party program to unzip the archive, for example 7zip.
ok, i see that if i use 7zip this problem is gone.
@Kaiserludi wrote:
I can reproduce the obj folder issue when trying to build the LoadBalancing-cpp solution. We will fix this for the next release
However it is not necessary at all to rebuild LoadBalaning-cpp yourself, when you do not modify its source. You can just use the prebuilt libraries that ship with the SDK.
I can't use the compiled lib, everything works in iOS but not in Android.
I have this error when i try to use the compiled .a with the loadbalancing+common-cpp+photon-cpp libs (.a) inside a plugin.a for my game:
C:/Games/sdks/android-ndk-r12b/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -Wl,-soname,libS3DClient.so -shared --sysroot=C:/Games/sdks/android-ndk-r12b/build//../platforms/android-9/arch-arm ./obj/local/armeabi-v7a/objs/S3DClient/S3DClient.o -Wl,--whole-archive jni/prebuilt/plugins/armeabi-v7a/PhotonCloudAPI.a -Wl,--no-whole-archive jni/prebuilt/engine/armeabi-v7a/libS3DClient_Android.a C:/Games/sdks/android-ndk-r12b/build//../sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a -lgcc ./obj/local/armeabi-v7a/libopenal.so ./obj/local/armeabi-v7a/libssl.so ./obj/local/armeabi-v7a/libcrypto.so -no-canonical-prefixes -march=armv7-a -Wl,--fix-cortex-a8 -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -LC:/Games/sdks/android-ndk-r12b/build//../platforms/android-9/arch-arm/usr/lib -lGLESv2 -lEGL -ldl -llog -lc -lm -o ./obj/local/armeabi-v7a/libS3DClient.so
C:/Games/sdks/android-ndk-r12b/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.exe: error: jni/prebuilt/plugins/armeabi-v7a/PhotonCloudAPI.a: member at 246202 is not an ELF object
C:/Games/sdks/android-ndk-r12b/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.exe: error: jni/prebuilt/plugins/armeabi-v7a/PhotonCloudAPI.a: member at 2934242 is not an ELF object
C:/Games/sdks/android-ndk-r12b/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.exe: error: jni/prebuilt/plugins/armeabi-v7a/PhotonCloudAPI.a: member at 4720214 is not an ELF object
jni/prebuilt/plugins/armeabi-v7a/PhotonCloudAPI.a(PhotonCloudAPI.o):PhotonCloudAPI.cpp:function Callback_PhotonCloudAPI_setNumberOfPingsPerRegion(int, S3DX::AIVariable const*, S3DX::AIVariable*): error: undefined reference to 'ExitGames::LoadBalancing::Client::M_PINGS_PER_REGION'
looks like the Photon libs are not a valid elf format, why is that?
Kaiserludi
2016-08-16 13:30:00
Hi @juaxix.
Yes, of course it is not a valid elf file. If it was, then the file ending would be .so. It is a static library, not a dynamic one, so you must link against it statically.
@Kaiserludi wrote:
Hi @juaxix.
Yes, of course it is not a valid elf file. If it was, then the file ending would be .so. It is a static library, not a dynamic one, so you must link against it statically.
Ok ,thanks, I've achieved to compile it statically, but i have a new error once i run the apk:
W/dalvikvm(17802): Class init failed in newInstance call (Lcom/xixgames/photondemo/PhotonCloud_Demo;)
D/AndroidRuntime(17802): Shutting down VM
W/dalvikvm(17802): threadid=1: thread exiting with uncaught exception (group=0x41724e48)
E/AndroidRuntime(17802): FATAL EXCEPTION: main
E/AndroidRuntime(17802): Process: com.xixgames.photondemo, PID: 17802
E/AndroidRuntime(17802): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZNSsC1EPKcRKSaIcE" referenced by "libS3DClient.so"...
E/AndroidRuntime(17802): at java.lang.Runtime.loadLibrary(Runtime.java:364)
E/AndroidRuntime(17802): at java.lang.System.loadLibrary(System.java:526)
E/AndroidRuntime(17802): at com.xixgames.photondemo.PhotonCloud_Demo.
E/AndroidRuntime(17802): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(17802): at java.lang.Class.newInstance(Class.java:1208)
E/AndroidRuntime(17802): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
E/AndroidRuntime(17802): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2119)
E/AndroidRuntime(17802): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
E/AndroidRuntime(17802): at android.app.ActivityThread.access$800(ActivityThread.java:139)
E/AndroidRuntime(17802): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
E/AndroidRuntime(17802): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(17802): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(17802): at android.app.ActivityThread.main(ActivityThread.java:5103)
E/AndroidRuntime(17802): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(17802): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(17802): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
E/AndroidRuntime(17802): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
E/AndroidRuntime(17802): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 825): Force finishing activity com.xixgames.photondemo/.PhotonCloud_Demo
any idea of what's going on now?
Kaiserludi
2016-08-25 13:04:22
Hi @juaxix.
Sorry, but I am afraid I have never seen this error before.
My suggestion is to compare your Android.mk and Application.mk with the ones from the demos inside the SDK to see what you are doing differently.
Ok, I can do that.
Ah, how can compile the .a as .so?
Kaiserludi
2016-08-25 14:02:49
My recommendation is to just let your app link the .a files directly, as I can't see any advantage in using .so files instead, that would be big enough to justify the additional work involved.
Ok, I'm creating the .so now, but when i try to build ,if i use the android-ndk build for r12b and 4-1-3-3 android sdk, this error appears:
I think this is an error from the oldest versions...here it is my application.mk and android.mk for this .so and .apk
Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := loadbalancing-cpp-static-prebuilt
LOCAL_SRC_FILES := $(PHOTON_SDK_ROOT)/LoadBalancing-cpp/lib/loadbalancing-cpp-prebuilt/libloadbalancing-cpp-static_${APP_OPTIM}android$(TARGET_ARCH_ABI)$(MY_APP_NORTTI_SUFFIX).a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := photon-cpp-static-prebuilt
LOCAL_SRC_FILES := $(PHOTON_SDK_ROOT)/Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_${APP_OPTIM}android$(TARGET_ARCH_ABI)$(MY_APP_NORTTI_SUFFIX).a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := common-cpp-static-prebuilt
LOCAL_SRC_FILES := $(PHOTON_SDK_ROOT)/Common-cpp/lib/common-cpp-prebuilt/libcommon-cpp-static_${APP_OPTIM}android$(TARGET_ARCH_ABI)$(MY_APP_NORTTI_SUFFIX).a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := G:/ShivaProjects/PhotonCloud/Plugins/com.xixgames.photoncloudapi/Libs/Photon-AndroidNDK-Sdk_v4-1-3-3 ../inc/ ./
LOCAL_CFLAGS := -DEG_DEBUGGER -D__STDINT_LIMITS -D_EG_ANDROID_PLATFORM -DANDROID_NDK -Wno-psabi -fno-rtti -lstdc++ -std=c11 -lgnustl_static -lsupc
LOCAL_STATIC_LIBRARIES := loadbalancing-cpp-static-prebuilt photon-cpp-static-prebuilt common-cpp-static-prebuilt
LOCAL_MODULE := native
LOCAL_SRC_FILES := native.cpp
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -ldl -lstdc++ -std=c++11
include $(BUILD_SHARED_LIBRARY)
Application.mk
do you see something wrong over there @Kaiserludi ?
Thanks for your time and help
Kaiserludi
2016-08-31 12:28:02
Hi @juaxix.
Please change
APP_STL := gnuport_static
in your Application.mk into
APP_STL :=c++_static
4.1.3.3 requires the use of libc++.
Please note that this is about to change. Starting with 4.1.4.0 we will require the following 2 settings in Application.mk:
APP_STL := gnustl_static
APP_CPPFLAGS := -std=c++11
instead.
You can have a look at the Application.mk and Android.mk file of any of the demos inside the SDK for an example of a working configuration.
Oh, thanks @Kaiserludi ,it compiles now, and the next error is really large and weird. (line 1917)
http://pastebin.com/7Mt5cUKR
for this code in C++ used as a wrapper in Java:
extern "C"
{
class myListener : private ExitGames::LoadBalancing::Listener {
public:
ExitGames::LoadBalancing::Client mLoadBalancingClient;
//Constructor
myListener(): mLoadBalancingClient(*this, "--myid--", "0.1", 0,true,0)
{
}
void connect(){
mLoadBalancingClient.connect(
ExitGames::LoadBalancing::AuthenticationValues()
.setUserID(
ExitGames::Common::JString() + GETTIMEMS()
).setType(
0
).setParameters("username=yes&token=yes")
);
}
};
static myListener* listen2;
JNIEXPORT void JNICALL Java_com_example_photontest_MainActivity_sayHello ( JNIEnv *_pEnv, jobject obj )
{
static myListener* listen;
printf("Connecting!\n");
listen->connect();
return;
}
JNIEXPORT jdouble JNICALL Java_com_example_photontest_MainActivity_average
(JNIEnv *env, jobject thisObj, jint n1, jint n2) {
jdouble result;
printf("In C, the numbers are %d and %d\n", n1, n2);
result = ((jdouble)n1 + n2) / 2.0;
// jint is mapped to int, jdouble is mapped to double
return result;
}
}
used from this java
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.view.Menu;
public class MainActivity extends Activity {
// Declare a native method sayHello() that receives nothing and returns void
public static native void sayHello();
public static native double average(int n1, int n2);
// load the library - name matches jni/Android.mk
static
{
System.loadLibrary("native");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String str = new String("In Java, the average is " + average(3, 2));
System.out.println(str);
new AlertDialog.Builder(this).setMessage(str).show();
sayHello();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
i just want to test if i can load the .a from a java using a c++ jni wrapper
Kaiserludi
2016-08-31 16:53:00
extern "C"
{
class
That extern "C" has no effect on the class inside the {}.
Regarding your error:
I don't see any obvious problems in your code that could cause this.
My suggestion is to track down what exactly is causing the problem.
Does myListener::connect()
crash when being called from one of the provided demos? If not, then you need to find out, what your testapp does differently from our demos.
Thanks for the correction @Kaiserludi .
Well, finally i got it to compile your demoLoadbalancing project, the problem was that the directory was too deep in the hard-drive and it could not successfully copy files, I moved all to E:.
Testing your demo it appears: received error 1030 from client and then 1040 and disconnect. Something wrong?, before I go forward and try to integrate my changes into loadbalancing for android again and recompile,...
I think i'm very close to achieve it @Kaiserludi ! . A little more help :smile:
I was able to run with my code and test the game with your android demo and my loadbalancing code, as you see in the screenshots:
http://imgur.com/a/yAtDv
http://imgur.com/a/hDzHM
i've built the final plugin .a with my libs, everything compiled for debug, and now i dont know how to fix this compile error using the plugin.a in a game project for android
http://pastebin.com/PLXaSsDj
this is the Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := S3DClient_Android
LOCAL_SRC_FILES := prebuilt/engine/$(TARGET_ARCH_ABI)/libS3DClient_Android.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := openal
LOCAL_SRC_FILES := prebuilt/thirdparty/$(TARGET_ARCH_ABI)/libopenal.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ssl
LOCAL_SRC_FILES := prebuilt/thirdparty/$(TARGET_ARCH_ABI)/libssl.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := crypto
LOCAL_SRC_FILES := prebuilt/thirdparty/$(TARGET_ARCH_ABI)/libcrypto.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := PhotonCloudAPI
LOCAL_SRC_FILES := prebuilt/plugins/$(TARGET_ARCH_ABI)/PhotonCloudAPI.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
NDK_DEBUG_IMPORTS := 1
NDK_DEBUG_MODULES := 1
LOCAL_CFLAGS := -DANDROID_NDK -Wno-psabi -fno-rtti -std=c11 -lstdc -lgnustl_static -lsupc++ -DEG_DEBUGGER -D__STDINT_LIMITS -D_EG_ANDROID_PLATFORM
LOCAL_ARM_MODE := arm
LOCAL_MODULE := S3DClient
LOCAL_MODULE_FILENAME := libS3DClient
LOCAL_SRC_FILES := S3DClient.cpp
LOCAL_STATIC_LIBRARIES := S3DClient_Android
LOCAL_SHARED_LIBRARIES := openal ssl crypto
LOCAL_WHOLE_STATIC_LIBRARIES += PhotonCloudAPI photon-cpp-static-prebuilt libcommon-cpp-static-prebuilt loadbalancing-cpp-static
LOCAL_LDLIBS += -lGLESv2 -lEGL -ldl -llog -latomic
include $(BUILD_SHARED_LIBRARY)
and application .mk
I'm following the demoBalancing project as example to build this but it fails...
Kaiserludi
2016-09-01 16:39:37
Hi @juaxix.
Regarding the undefined references to the stdlib:
Well, from your log it looks like not the app, but the PhotonCloudAPI lib fails to build, but the .mk files that you show seem to be the ones for the app.
@Kaiserludi wrote:
Hi @juaxix.
It seems you have solved that by now?
Yes, I added my code to the loadbalancing in the demo project, recompiled and it worked :)
@Kaiserludi wrote:
Regarding the undefined references to the stdlib:
Well, from your log it looks like not the app, but the PhotonCloudAPI lib fails to build, but the .mk files that you show seem to be the ones for the app.
Yeah, what I was showing is the built of the app (apk of the game), with the already built plugin PhotonCloudAPI.a, but now that you mention it, i think i'm not doing it right :(
I'm using a script to extract all the .o and then add the objects in the .a (I can't use the ar rcs option because the photon .a are not elf files).
And this is the Makefile for the engine plugin + photon libs:
http://pastebin.com/RgpUMj1F
You know, originally, the engine generates an android project with that Makefile and with only the option of rcs ( $(AR) -rcs $(TARGET) $(OBJECTS)) ,so i changed it to be able to compile, with no success yet.
Ok, I'm compiling only for the arm-v7a with:
these are the instructions of the makefile:
http://pastebin.com/f1V1guHs
Thanks @Kaiserludi
Kaiserludi
2016-09-02 12:44:27
Hi @juaxix.
It looks like you are linking against both, stdc++ and c++_static. The former is the gnu stdlib, while the latter is the clang stdlib. I don't know what happens, when one links against multiple standard library implementations, but those 2 are not binary compatible to each other. This may be the reason for those undefined reference errors, as I did not see anything else suspicious (but I may have overlooked something).
I think that's not the problem,...I've just compiled both only with c++_static but got the same compile error for the app project
[exec] jni/prebuilt/plugins/armeabi-v7a/PhotonCloudAPI.a(Plugin.o):Plugin.c
pp:function _GLOBAL__sub_I_Plugin.cpp: error: undefined reference to 'std::ios_b
ase::Init::Init()'
http://libcxx.llvm.org/
Do you think the plugin Makefile is ok?, i would like to use another method, instead of the objects extract with AR to be included in the .a
Kaiserludi
2016-09-05 13:43:47
Hi @juaxix.
Maybe the cause is a missing
APP_STL := c++_static
line in the Application.mk of the plugin?
@Kaiserludi wrote:
Hi @juaxix.
Maybe the cause is a missing
APP_STL := c++_static
line in the Application.mk of the plugin?
The plugin does not use Application.mk or Android.mk, it's a Makefile, you can see there the -lc++_static parameter in CPPFLAGS, i tried changing these parameters but it all have the same result...
Kaiserludi
2016-09-05 17:03:42
Hi @juaxix.
Isn't CPPFLAGS for arguments that are passed to the compiler? I think there should be something like LDFLAGS or so for arguments that go to the linker. I think -lc++_static needs to go there.
Hello @Kaiserludi , finally, and with help i managed to compile the plugin as a static lib (.a) and use it in a game to build the apk (shared), using the photon libs as .a directly, it was a mix of changes of NDK, flags and makefile configuration.
Thanks for your time, and i'll post the plugin url for the engine in the forum soon!
Kaiserludi
2016-09-14 11:42:26
Hi @juaxix.
Thanks for the great news.
Ok, first compile as normal LoadBalancing Project, then, use the common-cpp,photon-cpp and loadbalancing libs (.a) in the static_plugin.a makefile as static prebuilt includes.
Use the same technique for the game makefile (build as shared), including the plugin.a as static together with the other 3 static photoncloud libs.
The flags,
Kaiserludi
2016-09-14 17:12:56
Thank you, @juaxix.
Note that although LoadBalancing-cpp ships with it's source for convenience it also ships with prebuilt binaries built from that exact source, so you only need to rebuilt it yourself, if you are actually modifying the source, which usually isn't necessary.
I got this error
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/demo.android.loadBalancing-GIL4HGl5AqJzcC3EdKzdFg==/base.apk"],nativeLibraryDirectories=[/data/app/demo.android.loadBalancing-GIL4HGl5AqJzcC3EdKzdFg==/lib/arm64, /system/lib64, /system/vendor/lib64]]] couldn't find "libdemoLoadBalancing.so"
It seems the system needs .so file. So I tried to get .so file with "ndk-build" command line.
Is this right?
Thank, Btw I tried with Android.mk file.
Generated by VisualGDB
LOCAL_PATH := $(call my-dir)
PHOTON_SDK_ROOT := $(LOCAL_PATH)/../../../..
include $(CLEAR_VARS)
LOCAL_MODULE := demoLoadBalancing
#VisualGDBAndroid: AutoUpdateSourcesInNextLine
LOCAL_SRC_FILES := ../../src/NetworkLogic.cpp AndroidNetworkLogic.cpp main.cpp
LOCAL_C_INCLUDES := $(PHOTON_SDK_ROOT) ../inc/ ../../shared/inc
LOCAL_CFLAGS := -Werror-implicit-function-declaration -Wall -DEG_DEBUGGER -D__STDINT_LIMITS -D_EG_ANDROID_PLATFORM
LOCAL_STATIC_LIBRARIES := loadbalancing-cpp-static-prebuilt photon-cpp-static-prebuilt common-cpp-static-prebuilt
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
$(call import-add-path, $(PHOTON_SDK_ROOT)/LoadBalancing-cpp/lib)
$(call import-module,loadbalancing-cpp-prebuilt)
This is Demo_loadbalancing project. I m working on this.
But the below error occured.
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/demo.android.loadBalancing-GIL4HGl5AqJzcC3EdKzdFg==/base.apk"],nativeLibraryDirectories=[/data/app/demo.android.loadBalancing-GIL4HGl5AqJzcC3EdKzdFg==/lib/arm64, /system/lib64, /system/vendor/lib64]]] couldn't find "libdemoLoadBalancing.so"
What is the solution?
Its my system structure.
Kaiserludi
2020-07-17 19:52:54
Hi @baymax.
You should just navigate to /Volumes/Data/temp/photon/Demos/demo_loadBalancing/android and then run ndk-build.cmd there and that's it.
This should not result in a "couldn't find "libdemoLoadBalancing.so" " error, because the Android.mk file does not look for that file, but rather creates it.
Thank for your answer @Kaiserludi
https://gofile.io/d/9KkFcg
https://gofile.io/d/dgLBwj
I added video and screen to show what is my issue after following your guide. I did not find there is no good answer in google search.
[arm64-v8a] SharedLibrary : libdemoLoadBalancing.so
jni/../../../../LoadBalancing-cpp/lib/loadbalancing-cpp-prebuilt/libloadbalancing-cpp-static_debug_android_arm64-v8a.a(AuthenticationValues.o): In function __static_initialization_and_destruction_0(int, int)': E:\a\Android\LoadBalancing-cpp/D:/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: undefined reference to
std::ios_base::Init::Init()'
E:\a\Android\LoadBalancing-cpp/D:/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: undefined reference to std::ios_base::Init::~Init()' E:\a\Android\LoadBalancing-cpp/D:/android-ndk/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:74: undefined reference to
std::ios_base::Init::~Init()'
Regards.
Kaiserludi
2020-07-21 16:40:01
Hi @baymax.
Those errors indicate an incompatibility between the stdlib version that your app links against and the one that the Photon libs link against.
The SDK provides libs that have been built against the gcc version of the stdlib (libstdc++) and libs that have been built against the clang version of the stdlib (libc++).
The former ones are used on default and the lattter ones have an additional 'libc++' postfix in their filenames.
It looks like your app links against the clang version of the stdlib and against those builds of Photon libs that link against the gcc version of the stdlib.
However your app and all 3rd party libs that your apps link to must agreed on using the same version of the stdlib as those 2 incompatible versions can't be mixed with each other.
Please see https://forum.photonengine.com/discussion/comment/42718/#Comment_42718 for instructions on how to link against the libc++ variants of the Photon libs.
Doing so should fix your errors.
Back to top