I was trying to make and Android app that uses SFML.
I successfully create all the .so and .a
E:\Android\SFML-master>cmake -DANDROID_ABI=armeabi-v7a -DCMAKE_TOOLCHAIN_FILE=cm
ake/toolchains/android.toolchain.cmake -DANDROID_NDK=E:\Android\android-ndk-r10e
-- Building for: Visual Studio 12 2013
CMake Warning at CMakeLists.txt:97 (message):
CMake might not properly support setting the STL. Make sure to adjust all
generated library projects!
-- Found JPEG: E:/Android/SFML-master/extlibs/libs-android/armeabi-v7a/libjpeg.a
-- Found OpenAL: E:/Android/SFML-master/extlibs/libs-android/armeabi-v7a/libopen
al.so
-- Found VORBIS: E:/Android/SFML-master/extlibs/libs-android/armeabi-v7a/libvorb
is.a
-- Found FLAC: E:/Android/SFML-master/extlibs/libs-android/armeabi-v7a/libFLAC.a
-- Configuring done
-- Generating done
-- Build files have been written to: E:/Android/SFML-master
E:\Android\SFML-master>
As you can see, all fine.
I import the sfml's default android example using ( import and ndk-build Android Project ) using the last version of Nvidia Nsight.
I had to change the original android.mk ( and the application.mk too ) of the example (because don't work at least for me)
my android.mk:
LOCAL_PATH := $(call my-dir)
## sfml-activity ##
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-activity-main
LOCAL_SRC_FILES := libsfml-activity-d.so
include $(PREBUILT_SHARED_LIBRARY)
## sfml-activity end ##
## sfml-system.so ##
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-system
LOCAL_SRC_FILES := libsfml-system-d.so
include $(PREBUILT_SHARED_LIBRARY)
## sfml-system.so end ##
## sfml-window.so ##
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-window
LOCAL_SRC_FILES := libsfml-window-d.so
include $(PREBUILT_SHARED_LIBRARY)
## sfml-window.so end ##
## sfml-graphics.so ##
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-graphics
LOCAL_SRC_FILES := libsfml-graphics-d.so
include $(PREBUILT_SHARED_LIBRARY)
## sfml-graphics.so end ##
## sfml-audio.so ##
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-audio
LOCAL_SRC_FILES := libsfml-audio-d.so
include $(PREBUILT_SHARED_LIBRARY)
## sfml-audio.so end ##
## sfml-network.so ##
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-network
LOCAL_SRC_FILES := libsfml-network-d.so
include $(PREBUILT_SHARED_LIBRARY)
## sfml-network.so end ##
## sfml-main ##
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-main
LOCAL_SRC_FILES := libsfml-main-d.a
include $(PREBUILT_STATIC_LIBRARY)
## sfml-main end ##
## sfml-example ##
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-example
LOCAL_SRC_FILES := main.cpp
LOCAL_SRC_FILES += String.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_STATIC_LIBRARIES := sfml-main
include $(BUILD_SHARED_LIBRARY)
## sfml-example end ##
## sfml-activity ##
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-start
LOCAL_SHARED_LIBRARIES := sfml-activity-main
include $(BUILD_SHARED_LIBRARY)
## sfml-activity end ##
I get this undefined:
1>------ Build started: Project: test, Configuration: Debug Tegra-Android ------
1> [armeabi-v7a] Gdbserver : [arm-linux-androideabi-4.8] ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/gdbserver
1> [armeabi-v7a] Gdbsetup : ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/gdb.setup
1> [armeabi-v7a] Install : libsfml-start.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-start.so
1> [armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
1> [armeabi-v7a] Compile++ thumb: sfml-example <= String.cpp
1> [armeabi-v7a] Install : libsfml-activity-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-activity-d.so
1> [armeabi-v7a] Install : libsfml-system-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-system-d.so
1> [armeabi-v7a] Install : libsfml-window-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-window-d.so
1> [armeabi-v7a] Install : libsfml-graphics-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-graphics-d.so
1> [armeabi-v7a] Install : libsfml-audio-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-audio-d.so
1> [armeabi-v7a] Install : libsfml-network-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-network-d.so
1> [armeabi-v7a] Install : libc++_shared.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libc++_shared.so
1> [armeabi-v7a] SharedLibrary : libsfml-example.so
1>E:\Android\prueba\test\test\jni\main.cpp(13): error : error: undefined reference to 'sf::Texture::loadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sf::Rect<int> const&)'
1>E:\Android\prueba\test\test\jni\main.cpp(21): error : error: undefined reference to 'sf::Music::openFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
1> collect2.exe: error: ld returned 1 exit status
1> make.exe: *** [../../../prueba/test/test/Tegra-Android/Debug//local/armeabi-v7a/libsfml-example.so] Error 1
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I add to the jni path String.hpp for resolve the undefined Sf::String() symbol, if i add Music.hpp and Texture.hpp start asking for more and more include...
As you can see i'm using debug libraries, but i tested in release ( i take care of don't mix them, i have both release/debug) even i tried with the stripped_libsfml-xxx.so that automatically generates NSight among the libsfml_xxx.so.
I try using esfml ( https://github.com/Sonkun/esfml ) i built fine but get the same linking symbols error.
I had to change LOCAL_WHOLE_STATIC_LIBRARIES for LOCAL_STATIC_LIBRARIES , using the first one (like in the original example) give me more a lot of undefined.
I used ARMEABI-V7A for compiling all .so and .a and try to make the .apk (because i don't find the option inside NSight to try with ARMEABI ) seems that only support V7 , V8, x86 , x86_64.
The STL type is the default one (GNU libstdc++ Static)
I use the sfml's cmake toolchain, even i tried all using ""another"" toolchain (seems to make the same result , https://github.com/taka-no-me/android-cmake/blob/master/android.toolchain.cmake , i don't know is both are the same)
The minAndroidApi lvl i use is 14 ( in making all .so and .a and the .apk)
The target and max are NotSpecified
Can someone help me?
I need to give more details?
Hey DarkRoku,
thank you very much! Updating the android project worked for me now!
Except that I have used a slightly different command:
android update project --path <absolute/path/to/sfml/android/example> --target 5
where '--target 5' stands for android-19.
The currently available targets can be seen with the following command:
android list targets
But when it cames to build the project I struggle a bit.
In the directory of the android example I type 'ndk-build' and it print's this:
Android NDK: jni/Android.mk: Cannot find module with tag 'sfml' in import path
It seems to me that the error's source is this line in the Android.mk:
$(call import-module,sfml)
So I googled and found out that I have to set NDK_MODULE_PATH enviroment variable to the parent path of the module.
Great, but what is the sfml module? It seems logical to me that it should be the path to the generated files with MSYS (or maybe the library files generated with make?)
But everytime I try another path it just prints the same error :(
I used forward slashes in the path.
And in all the makefiles is written sth. about shared librarys, does it mean I have to build sfml as shared library and not as static?
thx for your help :)
cookie
The ndk search the module on the path $ndk/sources
The module is a folder, when you see in your Android.mk:
$(call import-module,sfml)
you are telling the ndk to search the module in this path:
$ndk/sources/module_name
in your case:
$ndk/sources/sfml
If you executed the command:
make && make install
make install
will install the module sfml in your $ndk/source path.
If the ndk can't find module sfml means that there is no folder named sfml in yours $ndk/source directory.
The module will contain an Android.mk file that will tell to the ndk who to link sfml with the libs you have built.
You don't need to worry about the module, all you need to type on the sfml installation is to execute.
make && make install
and sfml will do all the job for you. Thanks Laurent and others team's members.
The think about i'm thinking is that Android have support for openGL ES2.0 3.0 and 3.1, these versions allows shaders, in the current sfml build for android sfml don't allow shaders :(
Well, the Android.mk must appear.
But i will upload my sfml folder inside the $ndk/sources
Inside you will enconter the Android.mk, includes,libs (for armeabi-v7a),etc.
link: http://s000.tinyupload.com/index.php?file_id=10478807811861178411 (http://s000.tinyupload.com/index.php?file_id=10478807811861178411)
Hope it help you. ;)
PD: my sfml files are modified by me.
This means that if you use my .so the entry point is not main, is int myCustomEntryPoint( int argc , char* argv[] , ANativeActivity* activity )
I did this for expose ANativeActivity pointer.
THANK YOU man! It finally works ;D
With your sfml folder does it compile and run on android :)
Of course with the modification you have to change the main.cpp slightly:
#include <android/native_activity.h>
int myCustomEntryPoint( int argc , char* argv[] , ANativeActivity* activity )
{
// ...
}
My own compiled and installed sfml package looks a bit different, but I will investigate and still try to build my own sfml :) But for now I use yours :)
thank you!
cookie