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=19298It 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.0I did:
cmake --build . --target install --config Releasein armeabi and armeabi-v7a
Sadly:
android update project --target 1 --path . --name SFML-Exampledid not work for me, but:
android update project --target "android-23" --path .next I did:
ndk-build
ant debugGot 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).