godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.71k stars 574 forks source link

Compiling for Android fails due to missing symbol #372

Open 2shady4u opened 4 years ago

2shady4u commented 4 years ago

Hello, I can't seem to get any Android build working due to a missing symbol issue. I'm compiling on an Ubuntu LTS "Bionic Beaver" machine using following commands:

aarch64-linux-android29-clang -fPIC -o src/gdsqlite.os -c src/gdsqlite.cpp -g -O3 -std=c++14 -Igodot-cpp/include -Igodot-cpp/include/core -Igodot-cpp/include/gen -Igodot-cpp/godot_headers

aarch64-linux-android29-clang -fPIC -o src/library.os -c src/library.cpp -g -O3 -std=c++14 -Igodot-cpp/include -Igodot-cpp/include/core -Igodot-cpp/include/gen -Igodot-cpp/godot_headers

aarch64-linux-android29-clang -fPIC -o src/sqlite/sqlite3.os -c src/sqlite/sqlite3.c -g -O3 -Igodot-cpp/include -Igodot-cpp/include/core -Igodot-cpp/include/gen -Igodot-cpp/godot_headers

aarch64-linux-android29-clang -o demo/addons/godot-sqlite/bin/arm64v8/libgdsqlite.so -shared src/gdsqlite.os src/library.os src/sqlite/sqlite3.os -Lgodot-cpp/bin -lgodot-cpp.android.debug.arm64v8

Unfortunately running this (with remote debug enabled) gives following errors in the console:

E 0:00:01.036   reflection_atlas_set_size: Condition "status != 0x8CD5" is true. Continuing.
  <C++ Source>  drivers/gles3/rasterizer_scene_gles3.cpp:526 @ reflection_atlas_set_size()

(Which is spammed 10+ times in the console!) and probably more dire:

E 0:00:16.154   open_dynamic_library: Can't open dynamic library: libgdsqlite.so, error: dlopen failed: cannot locate symbol "_ZTVN10__cxxabiv120__si_class_type_infoE" referenced by "/data/app/org.godotengine.sqlitedemo-2/lib/arm64/libgdsqlite.so"....
  <C++ Error>   Condition "!p_library_handle" is true. Returned: ERR_CANT_OPEN
  <C++ Source>  platform/android/os_android.cpp:233 @ open_dynamic_library()

Anyone has any idea what I'm doing wrong?

2shady4u commented 4 years ago

I have the exact same issue on windows (when you remove the unnecessary /nologo flag )

Also this fails with the SimpleLibrary example code as well...

anyone know the solution?

zhangshiqian1214 commented 4 years ago

I have the same problem, Should we add dynamic library to build.gradle ?

zhangshiqian1214 commented 4 years ago

Hello, I can't seem to get any Android build working due to a missing symbol issue. I'm compiling on an Ubuntu LTS "Bionic Beaver" machine using following commands:

aarch64-linux-android29-clang -fPIC -o src/gdsqlite.os -c src/gdsqlite.cpp -g -O3 -std=c++14 -Igodot-cpp/include -Igodot-cpp/include/core -Igodot-cpp/include/gen -Igodot-cpp/godot_headers

aarch64-linux-android29-clang -fPIC -o src/library.os -c src/library.cpp -g -O3 -std=c++14 -Igodot-cpp/include -Igodot-cpp/include/core -Igodot-cpp/include/gen -Igodot-cpp/godot_headers

aarch64-linux-android29-clang -fPIC -o src/sqlite/sqlite3.os -c src/sqlite/sqlite3.c -g -O3 -Igodot-cpp/include -Igodot-cpp/include/core -Igodot-cpp/include/gen -Igodot-cpp/godot_headers

aarch64-linux-android29-clang -o demo/addons/godot-sqlite/bin/arm64v8/libgdsqlite.so -shared src/gdsqlite.os src/library.os src/sqlite/sqlite3.os -Lgodot-cpp/bin -lgodot-cpp.android.debug.arm64v8

Unfortunately running this (with remote debug enabled) gives following errors in the console:

E 0:00:01.036   reflection_atlas_set_size: Condition "status != 0x8CD5" is true. Continuing.
  <C++ Source>  drivers/gles3/rasterizer_scene_gles3.cpp:526 @ reflection_atlas_set_size()

(Which is spammed 10+ times in the console!) and probably more dire:

E 0:00:16.154   open_dynamic_library: Can't open dynamic library: libgdsqlite.so, error: dlopen failed: cannot locate symbol "_ZTVN10__cxxabiv120__si_class_type_infoE" referenced by "/data/app/org.godotengine.sqlitedemo-2/lib/arm64/libgdsqlite.so"....
  <C++ Error>   Condition "!p_library_handle" is true. Returned: ERR_CANT_OPEN
  <C++ Source>  platform/android/os_android.cpp:233 @ open_dynamic_library()

Anyone has any idea what I'm doing wrong?

this problem my here is ok, "cannot locate symbol "_ZTVN10cxxabiv120si_class_type_infoE" here is not link library libstd++, and your c code need use aarch64-linux-android29-clang compile and you c++ code need use aarch64-linux-android29-clang++ compile. when i try do this my project is ok.

smeikx commented 4 years ago

Thank you so much, @zhangshiqian1214! I made a pull request to fix this in the README.

piiertho commented 4 years ago

Hi @2shady4u ! Wouldn't it be easier to use ndk-build for your usecase ? Exemples can be found here: https://github.com/utopia-rise/fmod-gdnative https://github.com/utopia-rise/godot-2.5D-isometric-map-editor