![]() Extract the archive and copy the src and include directories to the Visual Studio project directory. This can be downloaded as an archive from the website, currently at version 2.0.5, although other versions should be similar if not the same. The first thing to do is add the SDL2 source code to the project. The x86 configuration is useful because these builds can be used with the x86 HAXM accelerated version of the Android emulator which runs much more quickly on a desktop computer than the ARM version. Each of these will need the same modifications applied if you intend to use them, although I'll only cover the ARM configuration here. It's also worth noting that the project has four configurations, ARM, ARM64, x86 and 圆4. This will provide the basis for what's needed to build SDL2 as a shared library, although a few settings will need to be changed. Call the project SDL2 so that Visual Studio will automatically give the library file the correct name when it gets compiled. From the templates menu select Dynamic Shared Library. ![]() ![]() Other libraries should follow the same process more or less.Īssuming that Visual Studio 2015 or 2017 is installed along with the cross-platform development options (make sure to check this when installing VS) the first thing to do is create an empty solution, then add a new project. I shall be concentrating on describing what it takes to build SDL2, link it to an Android java project, and have it display something with some custom code, starting with the SDL2 library. If you're also writing a library to share code with other platforms the project count jumps to four, or more if you wish to include libraries such as SDL_image. This means that, at the very least, you need to create two Visual Studio projects - plus a third to contain your own code. Fortunately the SDL author provides the java source file needed within an example ndk project - it just needs a little work to include it in Visual Studio. On Android, however, SDL2 does not run as a native activity application, rather it needs to be linked and invoked via a java activity so that hardware events such as input may be correctly handed down to the native code. Generally in these scenarios you link to SDL as you would any other library and start coding away. SDL2 projects on Android differ slightly to those created for desktop applications on platforms such as linux or Windows. This post, then, is my attempt to best document what I did to get the project building and running on my now aging Moto G so that others - and most likely my future self - may possibly be spared the hair pulling I've endured this last week. I am, in particular, interested in game development so it made sense to me to create an SDL2 based project as SDL supports Android from the go - but setting it up in Visual Studio required a lot of trial and error. Unfortunately the documentation for Visual Studio specific native development seems to have fallen a little by the way, or at least is very dry on the MSDN. ![]() This really appeals to me as I tend to favour the Visual Studio environment, so I thought it was finally time to see what I could do. For the last year or so Visual Studio 2015 (and now 2017) has had the ability to build Android applications using native code compiled with the Android ndk. ![]()
0 Comments
Leave a Reply. |