Last Updated 2/2/15
Since there are so many flavors of Linux these tutorials might not work on your Linux set up. If you've tried everything and are still having problems, contact me and I'll try to add on a distro specific fix. In the age of packaging managers, a lot of the work is done for you when installing libraries. You'll need root privileges to install packages so make sure to use 'su' or 'sudo' if you're not logged in as root.
Make sure you have updated to the latest version of your distro because your older package manager may not support the latest version of SDL 2.
1) For those of you who have Advanced Packaging Tool available (ie Ubuntu and Debian) you'll want to search the apt-get cache to find the current SDL 2 version to install. You can search the apt-get available packages using the command:
Extract the archive and cd to the folder that got extracted. Configure the installation using
4) Now that you've installed the development libraries, it's time to start up your IDE/compiler.
Make sure you have updated to the latest version of your distro because your older package manager may not support the latest version of SDL 2.
1) For those of you who have Advanced Packaging Tool available (ie Ubuntu and Debian) you'll want to search the apt-get cache to find the current SDL 2 version to install. You can search the apt-get available packages using the command:
apt-cache search libsdl2
You'll want to download the development version of SDL 2. As of the last update of this tutorial, the development package of SDL 2 is libsdl2-dev. You can install this package using the commandapt-get install libsdl2-dev
2) If you use the Yellow dog Updater, Modified (used in Fedora and CentOS) you can enter the command:yum search SDL2-devel
To search for the SDL 2 developers package. As of the last update of this tutorial, the developer package for SDL 2 is SDL2-devel. You can install this package using the command:yum install SDL2-devel
3) If somehow you don't have a package manager, you can install from the source the classic Unix way. Download the latest source from the SDL website.Extract the archive and cd to the folder that got extracted. Configure the installation using
./configure
Compile the source using the make commandmake all
Finally, install the package using the make commandmake install
Note: If you do a manual install you may have to specify where the headers and library files are for your compiler/IDE.4) Now that you've installed the development libraries, it's time to start up your IDE/compiler.
Select Your IDE/Compiler | |
Command Line | |
Code::Blocks | |
Back |
GPG Signature: The source code to this release has been signed by Sam Lantinga. You can get the public key from any keyserver with the key id 0xA7763BE6, or directly from Sam's home page: slouken-pubkey.asc. First, set up an empty project. Then, download SDL. For Dev C, download the 'MinGW' development library. Extract the files and move the folder into your project.
Here's the explanation.
Be gentle,report bugs,leave feedback on pages,or just edit them yourself! Thanks!
Using SDL
General
What is supported?
SDL 2.0.0 supports Windows XP, Windows Vista, Windows 7 and Windows 8.
SDL can be built with Visual C++, Cygwin, MinGW, and Dev-C++.
For the latest information see the page about Installation.
Windows 2000
I'm running Windows 2000 and I can't copy SDL.dll!
For some reason, archives created on Linux have the 'Encrypted' property set when unpacked on Windows 2000. This can be unset by pushing Advanced from the General tab of the properties window and unchecking Encrypt contents check box. The files can then be copied normally.
Developing with SDL
Windows CE
Can I build SDL for Windows CE?
SDL 1.2 is not officially supported on Windows CE, but some people have successfully built and run SDL applications on Windows CE.
SDL 1.2.5 and newer contain project files and information on building SDL 1.2 for Windows CE. Take a look at the file README.WinCE in the source archive for more information.
There is no support for Windows CE in SDL 2.0.
Visual C++
How do I use SDL with Visual C++?
Read the file 'VisualC.html' included with both the SDL Visual C++ development archive, and the SDL source archive.
When using Visual C++ I get 'fatal error C1083: Cannot open include file: 'windows.h': No such file or directory'
You need to install the platform SDK, as described here: http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
When using Visual C++ I get link errors relating to MSVCRT.LIB or LIBC
SDL is dynamically linked with the multi-threaded version of the Microsoft Visual C runtime. You need to edit your project settings, go to the C++ language tab, change the listbox to 'Code Generation' settings, and then change the runtime library to 'Multi-threaded DLL'. Make sure you do this with all projects that you link into your application.
When using Visual C++ 5, I get the following error message: SDL.lib : fatal error LNK1106: invalid file or disk full
This happens with Visual C++ 5, if you use the prebuilt SDL library and have not updated to the latest service pack.
Why can't I use Visual C++ debugger with SDL 1.2 applications?
You need to pass the SDL_INIT_NOPARACHUTE flag to your calls to SDL_Init() to make the msvc debugger work. Otherwise the debugger will be unable to trace exceptions, and other debugging features like run to cursor won't work.
Why does the Visual C++ debugger freeze at every breakpoint when debugging SDL apps?
The DirectX drivers have a system lock while you have video surfaces locked. To avoid this, you can set the video driver to GDI by setting the SDL_VIDEODRIVER environment variable to: windib. Since this changes video and mouse/keyboard input drivers, you'll see a difference in performance and features available, but you'll be able to debug your application more easily.
gcc
![Install Install](https://loka.developpez.com/tutoriel/sdl/bibliotheques/bib_devcpp/images/SDL_image_Devcpp.png)
How do I use SDL with gcc on Windows?
You can build and use SDL with gcc natively using either Cygwin or MinGW, or you can build a gcc cross-compiler targeting Windows from another platform. Setting up these environments is documented at: http://www.libsdl.org/extras/win32/gcc.html Once the build environment is set up, you can build your applications as though you are on an Unix. See the Linux FAQ for more details on building applications in this environment.
Dev-C++
How do I use SDL with Dev-C++?
Try the Dev-C++ tutorial available at: http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut1 (Archive). If you have problems, please contact the author of the tutorial.
There are also step by step instructions at: http://docs.deninet.com/sdl_on_dev_c.htm (Archive)
Choosing 'console application' in the project parameters will result in generating a program that will *systematically* make Vista users crash.
Choose 'gui application' instead of 'console application' when compiling for Vista.
MinGW/MYSYS
How do I use SDL with MinGW/MYSYS?
See the SDL and MYSYS/MinGW Tutorial
Miscellaneous
I get 'Undefined reference to 'SDL_main' ..
Make sure that you are declaring main() as:
You should be using main() instead of WinMain() even though you are creating a Windows application, because SDL provides a version of !WinMain() which performs some SDL initialization before calling your main code. If for some reason you need to use !WinMain(), take a look at the SDL source code in src/main/win32/SDL_main.c to see what kind of initialization you need to do in your !WinMain() function so that SDL works properly.
I get 'Undefined reference to 'WinMain@16'
Under Visual C++, you need to link with SDL2main.lib. Under the gcc build environments including Dev-C++, you need to link with the output of 'sdl-config --libs', which is usually: -lmingw32 -lSDL2main -lSDL2
I get undefined references to various SDL functions..
When you're compiling with gcc, you need to make sure the output of sdl-config follows your source file on the command line: gcc -o test test.c
sdl-config --cflags --libs
Dev C++ Install Sdl Software
If you're getting undefined references to functions in SDL_image or SDL_mixer, make sure you're actually linking with those libraries as well.
Why doesn't SDL_WM_ToggleFullScreen() work on Windows?
The semantics of SDL_WM_!ToggleFullScreen() are that switching between fullscreen and windowed mode is transparent to the application. The display pixels pointer does not change, the display depth does not change, etc. This cannot be guaranteed on Windows. However, there is a simple method you can use to change between fullscreen and windowed mode:
How do I avoid creating stdout.txt and stderr.txt?
![C++ C++](https://www.codegrepper.com/codeimages/new-keyword-in-cpp.png)
'I believe inside the Visual C++ project that comes with SDL there is a SDL_nostdio target you can build which does what you want(TM).'
'If you define 'NO_STDIO_REDIRECT' and recompile SDL, I think it will fix the problem.' (Answer courtesy of Bill Kendrick)
[edit|delete|history|feedback|raw]Ubuntu Install Sdl
[front page|index|search|recent changes|git repo|offline html]
Dev C++ Install Sdl Download
All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.
Wiki powered by ghwikipp.