Sign in to follow this  

SDL2 question

This topic is 1366 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Edited by Aliii

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

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.
 

Share this post


Link to post
Share on other sites

This topic is 1366 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this