Hi! I trying to build Android example with NDK on my Linux machine following official tutorial. I use latest versions of NDK and SDK, but needed to replace NDK tools folder with 25th version, because
android tool is deprecated since then.
If I build SFML with this command as pointed out at the tutorial:
cmake -DANDROID_ABI=armeabi-v7a -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/android.toolchain.cmake -DANDROID_STL=cstlport_shared ../..SFML builds fine, but when I try to build the project with ndk-build I get bunch of errors:
$ ndk-build
[armeabi-v7a] Prebuilt : libsfml-activity.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Install : libsfml-activity.so => libs/armeabi-v7a/libsfml-activity.so
[armeabi-v7a] Prebuilt : libsfml-graphics.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt : libsfml-audio.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt : libsfml-network.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt : libsfml-window.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt : libsfml-system.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] SharedLibrary : libsfml-example.so
jni/main.cpp:79: error: undefined reference to 'sf::String::String(char const*, std::__ndk1::locale const&)'
jni/main.cpp:82: error: undefined reference to 'sf::Texture::loadFromFile(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, sf::Rect<int> const&)'
jni/main.cpp:90: error: undefined reference to 'sf::Music::openFromFile(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)'
/home/arra/Android/Ndk/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function ANativeActivity_onCreate: error: undefined reference to 'std::basic_ios<char, std::char_traits<char> >::rdbuf(std::basic_streambuf<char, std::char_traits<char> >*)'
/home/arra/Android/Ndk/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::locale::~locale()'
/home/arra/Android/Ndk/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/home/arra/Android/Ndk/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/home/arra/Android/Ndk/sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'vtable for std::basic_streambuf<char, std::char_traits<char> >'
/home/arra/Android/Ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function (see go/missingkeymethod)
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libsfml-example.so] Error 1
Alright, this point also mentioned at the tutorial so I rebuilded with
-DANDROID_STL=c++_shared, but get another error:
/home/arra/Downloads/SFML/include/SFML/System/Err.hpp:32:19: fatal error: ostream: No such file or directory
#include <ostream>
^
compilation terminated.
None of these flags for DANDROID_STL working by one of the mentioned reasons:
system
system_re
gabi++_static
gabi++_shared
stlport_static
stlport_shared
gnustl_static
gnustl_shared
c++_static
c++_shared