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

Author Topic: SFML for android Gradle Build Fails  (Read 12306 times)

0 Members and 1 Guest are viewing this topic.

foo

  • Newbie
  • *
  • Posts: 20
    • View Profile
SFML for android Gradle Build Fails
« on: October 12, 2018, 11:12:12 pm »
I'm using NDK r18, SFML 2.5, Android API 24, Clang on MacOSX. STL=c++_shared.

And I made sure the STL value was the same across cmake and the generated makefiles.

I followed both the SFML official guide and a template found here on the forums. Both end with the same error. I'll show the command line example from the official guide only:

Here is the output

Error: undefined reference to 'sf::String::String(char const*, std::__ndk1::locale const&)'
  /Users/maverick/Library/Android/ndk/sources/third_party/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
  /Users/maverick/Library/Android/ndk/sources/third_party/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::locale::~locale()'
  /Users/maverick/Library/Android/ndk/sources/third_party/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
  /Users/maverick/Library/Android/ndk/sources/third_party/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::locale::~locale()'
  /Users/maverick/Library/Android/ndk/sources/third_party/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()'
  /Users/maverick/Library/Android/ndk/sources/third_party/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()'
  /Users/maverick/Library/Android/ndk/sources/third_party/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)'
  /Users/maverick/Library/Android/ndk/sources/third_party/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)'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [/Users/maverick/Code/Forks/SFML/examples/android/app/build/intermediates/ndkBuild/debug/obj/local/armeabi-v7a/libsfml-example.so] Error 1


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Here is the makefile

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := sfml-example

LOCAL_SRC_FILES := main.cpp

LOCAL_SHARED_LIBRARIES := sfml-activity
LOCAL_SHARED_LIBRARIES += sfml-graphics
LOCAL_SHARED_LIBRARIES += sfml-window
LOCAL_SHARED_LIBRARIES += sfml-audio
LOCAL_SHARED_LIBRARIES += sfml-network
LOCAL_SHARED_LIBRARIES += sfml-system
LOCAL_SHARED_LIBRARIES += openal

LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main

include $(BUILD_SHARED_LIBRARY)

$(call import-add-path,/Users/maverick/Library/Android/ndk/sources)
$(call import-module,third_party/sfml)
 

Someone on IRC said it might be link order so I've tried every possible combination. And I know it has to be a specific order: dependent libraries first so graphics then window then audio/network then system. As you can see I have that too.

I tried static and it installed but crashed on startup. Reading the official android C++ docs, they mention static is not suggested and use shared instead.

Help me get this to build and run right on android.
« Last Edit: October 12, 2018, 11:22:28 pm by foo »

 

anything