Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Android example fails to compile  (Read 2262 times)

0 Members and 1 Guest are viewing this topic.

KraXarN

  • Newbie
  • *
  • Posts: 12
  • Stuffs and things
    • View Profile
Android example fails to compile
« on: September 29, 2017, 04:42:54 pm »
I followed the tutorial on the Github wiki and tried to compile SFML for Android. I got til the make command, but got the error '#include <ostream> No such file or directory'. The tutorial told me to include '-DANDROID_STL=stlport_shared' in that case and after doing that it compiled just fine. However, the example project fails to compile after 'ndk-build' with the following error:
Code: [Select]
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&)'
D:/Android/android-ndk/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function std::basic_streambuf<char, std::char_traits<char> >::~basic_streambuf(): error: undefined reference to 'std::locale::~locale()'
D:/Android/android-ndk/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function std::basic_streambuf<char, std::char_traits<char> >::~basic_streambuf(): error: undefined reference to 'std::locale::~locale()'
D:/Android/android-ndk/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function std::priv::_Rb_tree<int, std::less<int>, std::pair<int const, sf::Vector2<int> >, std::priv::_Select1st<std::pair<int const, sf::Vector2<int> > >, std::priv::_MapTraitsT<std::pair<int const, sf::Vector2<int> > >, std::allocator<std::pair<int const, sf::Vector2<int> > > >::_M_erase(std::priv::_Rb_tree_node_base*): error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
D:/Android/android-ndk/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function std::priv::_Rb_tree<int, std::less<int>, std::pair<int const, sf::Vector2<int> >, std::priv::_Select1st<std::pair<int const, sf::Vector2<int> > >, std::priv::_MapTraitsT<std::pair<int const, sf::Vector2<int> > >, std::allocator<std::pair<int const, sf::Vector2<int> > > >::_M_erase(std::priv::_Rb_tree_node_base*): error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
D:/Android/android-ndk/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function std::priv::_Rb_tree<int, std::less<int>, std::pair<int const, sf::Vector2<int> >, std::priv::_Select1st<std::pair<int const, sf::Vector2<int> > >, std::priv::_MapTraitsT<std::pair<int const, sf::Vector2<int> > >, std::allocator<std::pair<int const, sf::Vector2<int> > > >::_M_erase(std::priv::_Rb_tree_node_base*): error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
D:/Android/android-ndk/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function std::priv::_Rb_tree<int, std::less<int>, std::pair<int const, sf::Vector2<int> >, std::priv::_Select1st<std::pair<int const, sf::Vector2<int> > >, std::priv::_MapTraitsT<std::pair<int const, sf::Vector2<int> > >, std::allocator<std::pair<int const, sf::Vector2<int> > > >::_M_erase(std::priv::_Rb_tree_node_base*): error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
D:/Android/android-ndk/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::locale::~locale()'
collect2.exe: error: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libsfml-example.so] Error 1
Tried on both Windows (Using minGW) and macOS, but both fail with the same error. Am I missing something?

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Android example fails to compile
« Reply #1 on: September 30, 2017, 10:45:43 am »
The current version of SFML with NDK version >12 do not work together when you use libc++ as STL implementation (has the best c++11 support). If stlport is fine for your usecase go with it, if you need libc++ you have two options:

1) Downgrade to NDK version 12
2) Use this pull request . With this pull request you have to use the toolchain provided by your NDK (NDK_ROOT/build/cmake) to build SFML, the rest works the same.


AlexAUT

KraXarN

  • Newbie
  • *
  • Posts: 12
  • Stuffs and things
    • View Profile
Re: Android example fails to compile
« Reply #2 on: September 30, 2017, 03:17:37 pm »
Okay, thanks a lot!  ;D