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

Author Topic: Android NDK - SFML-Example Build Error  (Read 4177 times)

0 Members and 2 Guests are viewing this topic.

Teyas

  • Newbie
  • *
  • Posts: 3
    • View Profile
Android NDK - SFML-Example Build Error
« on: May 07, 2017, 10:56:43 pm »
Hello there,

I've seen multiple threads but none have solved my issue so here I am.

I've installed all of the necessary Android development tools and I've built and installed the most recent SFML using CMake. SFML and its headers are in the AndroidNDK source folder after the install as they should be.

I then change directory to the example and perform

android update project --target 1 --path . --name SFML-Example which updates perfectly.

I then do "ndk-build" which outputs:

[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] Compile++ thumb: sfml-example <= main.cpp
[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       : libc++_shared.so <= <NDK>/sources/cxx-stl/llvm-libc++/libs/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&)'
C:/MobileDev/AndroidDev/android-ndk-r12b/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.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> >*)'
C:/MobileDev/AndroidDev/android-ndk-r12b/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::locale::~locale()'
C:/MobileDev/AndroidDev/android-ndk-r12b/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
C:/MobileDev/AndroidDev/android-ndk-r12b/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
C:/MobileDev/AndroidDev/android-ndk-r12b/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'vtable for std::basic_streambuf<char, std::char_traits<char> >'
C:/MobileDev/AndroidDev/android-ndk-r12b/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld.exe: the vtable symbol may be undefined because the class is missing its key function (see go/missingkeymethod)
collect2.exe: error: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libsfml-example.so] Error 1

However, if I change the application make file for the example to be "APP_STL := stlport_shared" it then becomes:

[armeabi-v7a] Install        : libsfml-activity.so => libs/armeabi-v7a/libsfml-activity.so
[armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
[armeabi-v7a] Prebuilt       : libstlport_shared.so <= <NDK>/sources/cxx-stl/stlport/libs/armeabi-v7a/
[armeabi-v7a] SharedLibrary  : libsfml-example.so
C:/MobileDev/AndroidDev/android-ndk-r12b/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.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> >*)'
C:/MobileDev/AndroidDev/android-ndk-r12b/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> const&)'
C:/MobileDev/AndroidDev/android-ndk-r12b/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
collect2.exe: error: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libsfml-example.so] Error 1

What exactly am I doing wrong for these 3 errors to persist? I believe all my environment variables are setup correctly but I have an inkling that may be where the error lies.
« Last Edit: May 07, 2017, 11:04:47 pm by Teyas »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android NDK - SFML-Example Build Error
« Reply #1 on: May 08, 2017, 09:02:25 am »
Still haven't found any time to look into this, but guess NDK r12 changed something that somehow breaks the build scripts in some odd way.

Have you tried using version 11?

Teyas

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Android NDK - SFML-Example Build Error
« Reply #2 on: May 08, 2017, 06:53:56 pm »
Hey buddy, thank you very much for the response - sorry I've been stuck at work all day.

No I haven't tried that, I wasn't aware it was an issue with the NDK; so I've learnt something. I'll start installing it now and let you know how it goes.

Thank you!

Teyas

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Android NDK - SFML-Example Build Error
« Reply #3 on: May 08, 2017, 10:24:33 pm »
Hello,

So after re-doing the process for NDK-r11c, I'm now getting this error

C:\MobileDev\SFML\examples\android>ndk-build
[armeabi-v7a] "Install        ": "libsfml-activity.so => libs/armeabi-v7a/libsfml-activity.so"
process_begin: CreateProcess(NULL, C:/MobileDev/AndroidDev/android-ndk-r11c/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded ./libs/armeabi-v7a/libsfml-activity.so, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [libs/armeabi-v7a/libsfml-activity.so] Error 2
make: *** Deleting file `libs/armeabi-v7a/libsfml-activity.so'

I haven't been able to look into much this evening so it may be something very simple.

EDIT: I changed the folder in NDK/source/sfml from lib to libs and now I get another error!

C:\MobileDev\SFML\examples\android>ndk-build
[armeabi] "Compile++ thumb": "sfml-example <= main.cpp"
process_begin: CreateProcess(NULL, C:/MobileDev/AndroidDev/android-ndk-r11c/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs/sfml-example/main.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -IC:/MobileDev/AndroidDev/android-ndk-r11c/build//../sources/cxx-stl/stlport/stlport -IC:/MobileDev/AndroidDev/android-ndk-r11c/build//../sources/cxx-stl//gabi++/include -Ijni -DANDROID -Wa,--noexecstack -Wformat -Werror=format-security -frtti -isystem C:/MobileDev/AndroidDev/android-ndk-r11c/build//../platforms/android-9/arch-arm/usr/include -c jni/main.cpp -o ./obj/local/armeabi/objs/sfml-example/main.o, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [obj/local/armeabi/objs/sfml-example/main.o] Error 2
« Last Edit: May 08, 2017, 11:16:30 pm by Teyas »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Android NDK - SFML-Example Build Error
« Reply #4 on: May 10, 2017, 03:46:21 pm »
Looks like you're mixing architectures. The SFML example by default builds for "armeabi-v7a", not "armeabi". As an alternative just build and install both.

SchabMan

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Android NDK - SFML-Example Build Error
« Reply #5 on: June 13, 2017, 01:03:19 pm »
Hi!

I'm trying to learn ndk and port my games to android and i got the same problem :/

I'm stuck on something like this:

c:\projects\SFML\examples\android>ndk-build
[armeabi-v7a] "Install        ": "libsfml-activity.so => libs/armeabi-v7a/libsfml-activity.so"
process_begin: CreateProcess(NULL, C:/projects/ndk/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded ./libs/armeabi-v7a/libsfml-activity.so, ...) failed.
make (e=2):The system cannot find the file specified.
make: *** [libs/armeabi-v7a/libsfml-activity.so] Error 2
make: *** Deleting file `libs/armeabi-v7a/libsfml-activity.so'

[EDIT]

I also tried to build armeabi. The same error
« Last Edit: June 13, 2017, 01:08:56 pm by SchabMan »