SDL 2.0 setup un Ubuntu

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

Recommended Posts

Hey guys, recently I started using Ubuntu 13.10 as transition from Windows 7 and I'm quite fresh at these linux tricks. Maybe anyone knows how I can setup and install SDL2 on Ubuntu to use with g++ and gdb. Thank you.

Share on other sites

This is how you do it: You go to google.com and enter install sdl 2 ubuntu'.

Share on other sites

I already tried articles from google, but  ./configure command don't work to me.

Share on other sites

With your initial description, we can't possibly do better than a generic article on the web. You need to give us a lot of detail about what you have tried, what error messages you got, etc.

And then again, this might not be the best forum to post your question: Both Ubuntu and SDL have forums where you can probably find people who know much more about this. Anyway, if you go through the trouble of giving us a chance at knowing what the problem is, I'll help you. But I can't get you very far with a description like "./configure command don't work to me".

Edited by Álvaro

Share on other sites

I'm sorry about disturbing your time, I already have  solution. I used Synaptic pachage manager to install SDL2 packages and compiled g++ with parameters -lSDL2 -L /path/to/libs -I /path/includes ;)

Edited by kaktusas2598

Share on other sites

Umm, no need for those things. AFAIK, most libraries in UNIX world either use pkg-config or custom libraryName-config programs to provide processor/linker flags. In the case of SDL2, I think the custom program is sdl2-config - i.e. running something like:

[source=bash]g++ file.cpp sdl2-config --cflags --libs[/source]

should be the preferred method on unix/linux machines, as it is portable. A more generic approach would be to use pkg-config:

[source=bash]g++ file.cpp pkg-config --cflags --libs sdl2[/source]

However, I would strongly recommend against compiling on the command line. It is a waste of time and productivity. Both Eclipse and QtCreator are great IDEs for C++, and you should use one if you want to focus on getting stuff done and not on compiling. If you are *really* intent on learning how to compile on linux, at least look up make files and normal build systems like cmake and scons.

A few tips on linux distributions: although library imports are generally named libNAME.a, you include them via their name only (-l NAME) - unlike Visual Studio. All libraries installed via the package manager (in your case, apt) go to /usr/include (in case you want to browse them manually). Usually you can execute shell commands and include the output of those commands in another command. That is why I've put accents () and not quotes (') around sdl2-config and pkg-config. Those programs print to stdout, but with the accents syntax you capture the output and put in in your command string. You can view documentation on C functions via the man command, e.g. man 3 printf would show you the documentation for printf. Some packages install man pages as well, but most don't. I haven't found the manual pages particularly useful for c++, though.

[Note: I don't have an ubuntu box atm and I haven't spell-checked the commands]