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

Author Topic: [SOLVED] Cannot ndk-build example  (Read 3663 times)

0 Members and 1 Guest are viewing this topic.

Cyrana

  • Newbie
  • *
  • Posts: 21
    • View Profile
[SOLVED] Cannot ndk-build example
« on: February 22, 2017, 01:26:07 am »
Hello forum : )

A few stats to begin with:
OS: Windows 7 - 64 bit
NDK: r12b
SFML: 2.4.2

I built for armeabi and armeabi-v7a and installed both to the NDK into the SFML-module.

First, I used the "Visual Studio 15 2017" compiler, being aware of it probably not going to work.
It failed during ndk-build.

So I used MSYS, did build and make, but ended up having the same error once trying to ndk-build.

The error:
[...]\SFML\examples\android>ndk-build
[armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
jni/main.cpp:1:27: fatal error: SFML/System.hpp: No such file or directory
 #include <SFML/System.hpp>

I did not change anything about SFML's source-tree. Just added build with its 4 sub-folders for each target.
But once I copy the SFML folder with its System.hpp into the example, a new set of errors occur: DO NOT DO THIS - LET THE NDK SORT THINGS OUT VIA SFML'S INSTALLED MODULE
[...]\examples\android>ndk-build
[armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
[armeabi-v7a] Prebuilt       : libc++_shared.so <= <NDK>/sources/cxx-stl/llvm-li
bc++/libs/armeabi-v7a/
[armeabi-v7a] SharedLibrary  : libsfml-example.so
jni/main.cpp:24: error: undefined reference to 'sf::getNativeActivity()'
jni/main.cpp:57: error: undefined reference to 'sf::Time::asMilliseconds() const
'
jni/SFML/Graphics/Sprite.hpp:47: error: undefined reference to 'sf::Transformabl
e::~Transformable()'
jni/SFML/Graphics/Sprite.hpp:47: error: undefined reference to 'vtable for sf::S
prite'
[...]/NDK/android-ndk-r12b/build//../toolchains/arm-linux-androideabi-4.9/prebu
ilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-li
nux-androideabi/bin/ld.exe: the vtable symbol may be undefined because the class
 is missing its key function (see go/missingkeymethod)
jni/main.cpp:79: error: undefined reference to 'sf::VideoMode::getDesktopMode()'

jni/main.cpp:79: error: undefined reference to 'sf::String::String(char const*,
std::__ndk1::locale const&)'
jni/main.cpp:79: error: undefined reference to 'sf::RenderWindow::RenderWindow(s
f::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
jni/main.cpp:81: error: undefined reference to 'sf::Texture::Texture()'
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:85: error: undefined reference to 'sf::Sprite::Sprite(sf::Texture c
onst&)'
jni/main.cpp:86: error: undefined reference to 'sf::Transformable::setPosition(f
loat, float)'
jni/main.cpp:87: error: undefined reference to 'sf::Texture::getSize() const'
jni/main.cpp:87: error: undefined reference to 'sf::Texture::getSize() const'
jni/main.cpp:87: error: undefined reference to 'sf::Transformable::setOrigin(flo
at, float)'
jni/main.cpp:89: error: undefined reference to 'sf::Music::Music()'
jni/main.cpp:90: error: undefined reference to 'sf::Music::openFromFile(std::__n
dk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<c
har> > const&)'
jni/main.cpp:91: error: undefined reference to 'sf::Music::~Music()'
jni/main.cpp:93: error: undefined reference to 'sf::SoundStream::play()'
jni/main.cpp:95: error: undefined reference to 'sf::RenderTarget::getDefaultView
() const'
jni/main.cpp:97: error: undefined reference to 'sf::Window::isOpen() const'
jni/main.cpp:101: error: undefined reference to 'sf::Window::pollEvent(sf::Event
&)'
jni/main.cpp:106: error: undefined reference to 'sf::Window::close()'
jni/main.cpp:109: error: undefined reference to 'sf::View::setSize(float, float)
'
jni/main.cpp:110: error: undefined reference to 'sf::View::setCenter(float, floa
t)'
jni/main.cpp:111: error: undefined reference to 'sf::RenderTarget::setView(sf::V
iew const&)'
jni/main.cpp:116: error: undefined reference to 'sf::Transformable::setPosition(
float, float)'
jni/main.cpp:118: error: undefined reference to 'sf::milliseconds(int)'
jni/main.cpp:125: error: undefined reference to 'sf::RenderTarget::clear(sf::Col
or const&)'
jni/main.cpp:126: error: undefined reference to 'sf::RenderTarget::draw(sf::Draw
able const&, sf::RenderStates const&)'
jni/main.cpp:127: error: undefined reference to 'sf::Window::display()'
jni/main.cpp:89: error: undefined reference to 'sf::Music::~Music()'
jni/main.cpp:81: error: undefined reference to 'sf::Texture::~Texture()'
jni/main.cpp:128: error: undefined reference to 'sf::RenderWindow::~RenderWindow
()'
jni/main.cpp:83: error: undefined reference to 'sf::Texture::~Texture()'
jni/main.cpp:83: error: undefined reference to 'sf::RenderWindow::~RenderWindow(
)'
jni/main.cpp:129: error: undefined reference to 'sf::Color::White'
jni/main.cpp:129: error: undefined reference to 'sf::RenderStates::Default'
collect2.exe: error: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libsfml-example.so] Error 1
 

Tried this thread already: http://en.sfml-dev.org/forums/index.php?topic=19298
It inspired me to try MYSYS.

This is the android.mk:
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := sfml-example

LOCAL_SRC_FILES := main.cpp

LOCAL_SHARED_LIBRARIES := sfml-system
LOCAL_SHARED_LIBRARIES += sfml-window
LOCAL_SHARED_LIBRARIES += sfml-graphics
LOCAL_SHARED_LIBRARIES += sfml-audio
LOCAL_SHARED_LIBRARIES += sfml-network
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main

include $(BUILD_SHARED_LIBRARY)

$(call import-module,sfml)
 

Thanks for taking your time to read my thread : ) Have a sweet day/evening : )

SOLUTION!
I managed to build and debug it : )
This thread helped me: http://en.sfml-dev.org/forums/index.php?topic=20587.0

I did: cmake --build . --target install --config Release
in armeabi and armeabi-v7a

Sadly: android update project --target 1 --path . --name SFML-Example
did not work for me, but:
android update project --target "android-23" --path .
next I did:
ndk-build
ant debug


Got my SFML-Example-debug.apk
This pretty much shows, it still got the --name SFML-Example from the upper android update, but the --target 1 probably is too low for my NDK - no idea.

But whenever I press the home-button or leave the app somehow, "Unfortunately, SFML has stopped." : /
Well, that might be an issue with the example (I hope).

« Last Edit: February 22, 2017, 11:13:23 am by Cyrana »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: [SOLVED] Cannot ndk-build example
« Reply #1 on: February 22, 2017, 11:12:13 am »
Did you build the "install" target after building SFML? Sounds like you're missing the proper include directories.

SFML should be located in "[NDK]/sources/SFML"

Cyrana

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: [SOLVED] Cannot ndk-build example
« Reply #2 on: February 22, 2017, 11:26:43 am »
Haha, sorry, I think I ninja'd you :' )
It seems it did not completely build it... it definitely had SFML in sources "[NDK]/sources/SFML" but well.

Can you say whether  "Unfortunately, SFML has stopped." is an error I did on my end? No edits on the example-projects. Just wondering if my build-process may failed at some point?

cvkfak

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [SOLVED] Cannot ndk-build example
« Reply #3 on: February 23, 2017, 05:44:27 am »

But whenever I press the home-button or leave the app somehow, "Unfortunately, SFML has stopped." : /
Well, that might be an issue with the example (I hope).
Is a bug that persist since 2.4, 2.3.2 do not have this bug, so i recommend to use 2.3.2 for android builds like me (if you wanna use the vibration feature with sf::getNativeActivity, patch the source code of sfml with this patch https://github.com/SFML/SFML/pull/1005/files ).

Cyrana

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: [SOLVED] Cannot ndk-build example
« Reply #4 on: February 23, 2017, 02:49:13 pm »
Did so, encountered a weird bug, though.

When I do as mentioned and reach the ndk-build point, it tries to use
[...]\android-ndk-r12b\toolchains\arm-linux-androideabi-4.8
instead of
[...]android-ndk-r12b\toolchains\arm-linux-androideabi-4.9

Had to cheat: Duplicate folder, rename the clone to arm-linux-androideabi-4.8.
Works. Sadly, I could not find a single file where it would state to use 4.8.
Unless NDKABI 23 is associated with 4.8? No idea, haha.

Thanks a lot, cvkfak! Did not try out the vibration-fix though, as I do not need it now.

I really hope SFML does not give up porting to Android : )!


cvkfak

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [SOLVED] Cannot ndk-build example
« Reply #5 on: February 24, 2017, 10:26:27 am »
Works. Sadly, I could not find a single file where it would state to use 4.8.
Unless NDKABI 23 is associated with 4.8? No idea, haha.

On YOUR-ANDROID-PROJECT-FOLDER/jni/Application.mk
where it says NDK_TOOLCHAIN_VERSION i think... not sure at all.

 

anything