Advertisement

SDL2 question

Started by April 20, 2014 07:21 PM
3 comments, last by fluffybeast 10 years, 7 months ago

I want to use SDL2 under Linux and Win within a C++ project. Can I just add the source code to my project and expect it to work? Are there some special dependencies? Thanks!

edit: this is the first time Im trying SDL.

You need to install it first.What version of Linux are you using?

I'm not sure how to do it on every platform, but I know you can install it via your package manager on Fedora and Arch. On Ubuntu or Miny you can follow this guide.

Advertisement
That would probably work, but it may introduce unwanted licensing issues - though SDL has a liberal license IIRC.

On Linux, if you're happy with the version of SDL that can be installed via the package manager, then that is the simplest route. If not, you can download or checkout the appropriate version and build / install it manually. Once installed, you'll need to configure your building toolchain to include the appropriate arguments. As a simple example, from the command line something like the following:

$ g++ main.cpp -o sdl-test `sdl-config --cflags --libs`
You can manually invoke the sdl-config to see what arguments it is passing to the compiler / linker. Generally, you don't actually build directly on the command line but instead using some kind of Make like tool and/or an IDE. You'll need to figure out how to ensure the relevant command line arguments are passed to the compiler / linker on a per-tool basis.

On Windows, if you use Visual Studio typically one downloads a precompiled version of the library. You may need to configure your project with the correct additional include / library directories, and the static libraries you want to link to. You'll also want to copy the SDL DLL into your project directory. If you are using the same toolchain as on Linux, then the process tends to be quite similar - just without the package manager.

Basic SDL should be standalone, you won't need other dependencies. If you want to use any of the add-on libraries, such as SDL_TTF, SDL_Image or SDL_Net, you may need to install their dependencies. This is a similar process, but simpler as you may not need the headers and static libraries, just the DLLs / shared objects.

Please read the SDL FAQ for more information on specific toolchains.

Thanks! Ive installed it on Linux, included the libs/header and it works fine. I guess I wont need to compile it myself.

You need to install it first.What version of Linux are you using?

Kubuntu. Ive found it through the package manager(libsdl2 and libsdl2-dev).

Thanks! Ive installed it on Linux, included the libs/header and it works fine. I guess I wont need to compile it myself.

You need to install it first.What version of Linux are you using?

Kubuntu. Ive found it through the package manager(libsdl2 and libsdl2-dev).

That's great! I'm glad they decided to add SDL2, much easier than having to compile it yoursefl.

This topic is closed to new replies.

Advertisement