pelya / commandergenius

Port of SDL library and several games to the Android OS.
http://libsdl-android.sourceforge.net/
GNU Lesser General Public License v2.1
531 stars 248 forks source link

Build problem with libc++ #105

Open protoman opened 5 years ago

protoman commented 5 years ago

Hello. I am trying to move from my own build system to the one from your SDL and also moving to clang from gcc, as support for gcc was dropped by google and we'll need to build for arm-64. Anyway, when building, I got error with some basic C++ stuff on linker: /home/iuri/Programas/android-studio/sdk/android-ndk-r20/sources/cxx-stl/llvm-libc++/include/ostream:275: error: undefined reference to 'std::uncaught_exception()' /home/iuri/Programas/android-studio/sdk/android-ndk-r20/sources/cxx-stl/llvm-libc++/include/new:320: error: undefined reference to 'operator delete(void*)' /home/iuri/Programas/android-studio/sdk/android-ndk-r20/sources/cxx-stl/llvm-libc++/include/new:239: error: undefined reference to 'operator new(unsigned int)'

The solution was to add AppLdflags='-lstdc++'. That fixes the build. But the thing is that, when running the app, it gives this error: 06-18 11:19:01.328 22704 22720 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found

While I can change your script to copy this shared library from the NDK to the libs folder so the generated APK will contain it, I wanted to know if I am doing something wrong in the build in first place.

I had to include llvm-libc++ dirs for it to find the headers, so that may be the reason: AppCppflags='-DANDROID -DHANDHELD -std=c++11 -I/home/iuri/Programas/android-studio/sdk/android-ndk-r20/sources/cxx-stl/llvm-libc++/include -I. -I./rockdroid -I./rockdroid/aux_tools -I./rockdroid/character -I./rockdroid/character/movement -I./rockdroid/file -I./rockdroid/file/format -I./rockdroid/file/v4 -I./rockdroid/graphic -I./rockdroid/objects -I./rockdroid/options -I./rockdroid/ports/android -I./rockdroid/scenes'

Also, I am using lastest ndk (r20) and APP_PLATFORM=android-21

Thanks.

pelya commented 4 years ago

I've also moved SDL repo to c++_shared library, because it is recommended by NDK documentation. To use it, add c++_shared to CompiledLibraries in AndroidAppSettings.cfg

Sorry for late reply.

On Tue, 18 Jun 2019, 17:39 Iuri Fiedoruk, notifications@github.com wrote:

Hello. I am trying to move from my own build system to the one from your SDL and also moving to clang from gcc, as support for gcc was dropped by google and we'll need to build for arm-64. Anyway, when building, I got error with some basic C++ stuff on linker: /home/iuri/Programas/android-studio/sdk/android-ndk-r20/sources/cxx-stl/llvm-libc++/include/ostream:275: error: undefined reference to 'std::uncaught_exception()' /home/iuri/Programas/android-studio/sdk/android-ndk-r20/sources/cxx-stl/llvm-libc++/include/new:320: error: undefined reference to 'operator delete(void*)' /home/iuri/Programas/android-studio/sdk/android-ndk-r20/sources/cxx-stl/llvm-libc++/include/new:239: error: undefined reference to 'operator new(unsigned int)'

The solution was to add AppLdflags='-lstdc++'. That fixes the build. But the thing is that, when running the app, it gives this error: 06-18 11:19:01.328 22704 22720 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found

While I can change your script to copy this shared library from the NDK to the libs folder so the generated APK will contain it, I wanted to know if I am doing something wrong in the build in first place.

I had to include llvm-libc++ dirs for it to find the headers, so that may be the reason: AppCppflags='-DANDROID -DHANDHELD -std=c++11 -I/home/iuri/Programas/android-studio/sdk/android-ndk-r20/sources/cxx-stl/llvm-libc++/include -I. -I./rockdroid -I./rockdroid/aux_tools -I./rockdroid/character -I./rockdroid/character/movement -I./rockdroid/file -I./rockdroid/file/format -I./rockdroid/file/v4 -I./rockdroid/graphic -I./rockdroid/objects -I./rockdroid/options -I./rockdroid/ports/android -I./rockdroid/scenes'

Also, I am using lastest ndk (r20) and APP_PLATFORM=android-21

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pelya/commandergenius/issues/105?email_source=notifications&email_token=AABF5QET2I6EO75NB74SDA3P3DXTJA5CNFSM4HZAY55KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G2FHWWQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AABF5QDJ2UWTKRJUJJCB2MLP3DXTJANCNFSM4HZAY55A .