Thursday, March 31, 2016

How Do I Set Up Visual Studio 2015 with SDL2 For Android, iOS, and Windows Development?

Leave a Comment

Visual Studio 2015 has integrated Android Emulator support. They even have a pre-made template to set up Windows Phone, Android, and iOS targets. It seems like there should be some way of setting up SDL 2.0 in the same solution to easily toggle between Android and Windows. I am really hoping for an existing template which includes SDL 2.0, or a tutorial on the subject.

Where am I at right now? I have a working code base which I've been maintaining in visual studio 2015 based on SDL 2.0, Quite some time back I ported it to Xcode on my mac manually and I was able to run in the emulator. I have not run on Android yet. The port in xcode has likely gone stale though as I've updated multiple libraries and it was three years ago.

My ideal answer to this question would result in a working Visual Studio 2015 project with SDL 2.0 configured for iOS, Android, and Windows. What I am looking for is a series of steps to create a template project that can be used as a starting point to get an OpenGL context initialized via SDL on Windows or the Android emulator.

This might be asking a lot, but I'm hoping someone has already done the work and can simply share it with the world here.

2 Answers

Answers 1

I searched a lot for you, unfortunately couldnt find a strict tutorial about what u exactly ask. I am sharing all things I found, I know it is not directly related to what you want but maybe can help:

include <SDL.h>     int main(int argc, char ** argv)     {         SDL_Init(SDL_INIT_VIDEO);         SDL_Quit();         return 0;     } 
  1. Go to http://www.libsdl.org/download-2.0.php and download SDL2-devel-2.0.4-VC.zip
  2. Open a folder under C namely SDL2, C:\SDL2, and extract the libraries inside the zip file to this folder.
  3. Open an empty c++ project in vs2015, go to its properties page and add ;C:\SDL2\include to the end of Configuration Properties -> Include Directories
  4. Again in properties page (same as 3), Go to Linker -> General and write C:\SDL2\lib\x86 to Additional Library Directories (x64 if u are using 64bit OS).
  5. Go to Linker -> Input on the same page and write SDL2.lib; SDL2main.lib instead what writing on Additional Dependencies.
  6. GO to Linker -> System and write Windows (/SUBSYSTEM:WINDOWS) to the SubSystem.
  7. Add main.cpp under Source folder in your project and its code will be the one at the top of this message. Run this code. If you use VS2013, your work would be done, but now u will receive some errors.

TO FIX:

  1. Go to https://buildbot.libsdl.org/sdl-builds/sdl-visualstudio/ and download the latest one at the bottom.
  2. Extract the libs inside the folder C:\SDL2
  3. Make sure you wrote C:\SDL2\lib\x86 under Linker -> General because x64 does not work for this task!
  4. Run the program again. If you receive an error: Go to C:\SDL2\lib\x86 and grab SDL2.dll and put it in your project’s Debug folder
  5. In your project’s properties, go to the Debugging section and change the value of Working Directory from $(ProjectDir) to $(SolutionDir)$(Configuration)\

This is how we install SDL2 to VS2015

Ref: http://gigi.nullneuron.net/gigilabs/setting-up-sdl2-with-visual-studio-2015/

This site might be useful as well: https://wiki.libsdl.org/Installation

Answers 2

An alternative is to develop apps with Unity(3D)/ LibGDX(2D) and not SDL, or get the assembly of your final SDL project and run it as a dll (as assembly so you can run it in the Android OS, for example).

Compiler options for SDL are just like for any usual SDL IDE (CodeBlocks).

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment