SFML community forums

General => General discussions => Topic started by: Hlymur on March 28, 2016, 03:39:12 pm

Title: Build SFML to Android-Port with VS 2015
Post by: Hlymur on March 28, 2016, 03:39:12 pm
Hey @all,

at first let me point out, that i'm new to this forum (forwarded from the german SFML-forum) and maybe this topic need to be moved!
Microsoft introduced native-android-development with VS 2015. I tried to build the SFML-libs with VS 2015 but had no success.
I tried some different "google-results", but nothing worked:
I've used this tutorial (https://github.com/SFML/SFML/wiki/Tutorial:-Building-SFML-for-Android) with the following result:
Code: [Select]
CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR specifies a platform to: 'Visual Studio 14 2015 ARM'
Next, i found an interesting MS-article (https://blogs.msdn.microsoft.com/vcblog/2015/12/15/support-for-android-cmake-projects-in-visual-studio/), about a patched CMake-Version.
By following the steps, CMake starts working, but i got this error-msg:
Code: [Select]
CMake Error at src/SFML/Graphics/CMakeLists.txt:119 (find_host_package):
Unknown CMake command "find_host_package".
By using this command:
Code: [Select]
cmake -G "Visual Studio 14 2015 ARM" -DCMAKE_SYSTEM_NAME=VCMDDAndroid -DANDROID_ABI=armeabi -DANDROID_NDK=C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e ..\..
I'm not that familiar with CMake to fix this error. So maybe u can help me?  :)

Or at least u've some tips or experience building SFML to Android with VS 2015.

Also i could use Android Studio, but i don't like the eclipse-like IDE, but if its more easier, i would try it ;-)


Title: Re: Build SFML to Android-Port with VS 2015
Post by: ChronicRat on March 29, 2016, 12:33:42 pm
VS2015's android support is raw and awful. Use this - https://developer.nvidia.com/nvidia-nsight-tegra
Forum - https://devtalk.nvidia.com/default/board/82/nsight-tegra-visual-studio-edition/1/
Example of SFML VS project is here - https://bitbucket.org/SteelRat/gipe/src/725d1a1242ff/deps/sfml/
It's for old Nsight version and for VS2013, but I think it's good as example.
Title: Re: Build SFML to Android-Port with VS 2015
Post by: Hlymur on March 29, 2016, 04:15:16 pm
thx, that helps a lot!

With Nsight Tegra i compiled the SFML-libs!

Next, i created a test-project (New Project > Nsight Tegra > Android Native Application).
I've deleted the "glue"-Files, add the include and lib paths to the project and put following code to the main.cpp:
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main( int argc , char *argv[] )
        sf::RenderWindow window{ sf::VideoMode::getDesktopMode() , "" };

        sf::RectangleShape shape;

        shape.setSize( { 100.f,100.f } );
        shape.setFillColor( sf::Color::Red );
        shape.setPosition( 10.f , 10.f );

        sf::View view = window.getDefaultView();

        while( window.isOpen() )
                sf::Event event;

                while( window.pollEvent( event ) )
                        if( event.type == sf::Event::Closed )

                        if( event.type == sf::Event::Resized )
                                view.setSize( event.size.width , event.size.height );
                                view.setCenter( event.size.width / 2 , event.size.height / 2 );
                                window.setView( view );

                window.clear( sf::Color::White );
                window.draw( shape );

Last, i edited the AndroidManifest.xml:

After compiling i got 3 Files:

I copiedthis 3 files to my mobile-device and installed the .apk-file.
When i try to start the application i got the message, that the program has terminated.

I guess i need to copy the .so-files (including the sfml-libs) to a special place, but i don't know where :-S
On the other hand, .apk's i've already installed in my life never needn't to copy a shared-lib to a special place :(
Title: Re: Build SFML to Android-Port with VS 2015
Post by: Hlymur on March 30, 2016, 05:26:10 pm
Today i build the sfml-android-sample (with Commandline).

When i try to run the app on my device i got the message "Unfortunately, SFML has stopped."
Any ideas how to fix it?

PS: I followed these steps (https://github.com/SFML/SFML/wiki/Tutorial%3A-Building-SFML-for-Android) to build the example