Configure SDL in MinGW

I am currently trying to figure out how to configure SDL using MinGW. I saw a couple of sites that have methods (or rather, the same method that was republished), but I would prefer not to have a "quick" dirty "setting.

I see the sdl-conf file there, I have MSYS installed, and I downloaded the latest SDL 1.2 MinGW developer.

+4
source share
1 answer

The tutorial is here . He explains everything you need:

  • The first thing you need to do is download the SDL headers and binaries. You will find them on the SDL website, especially on this page.

Scroll down to the Development Libraries section and download the Mingw32 Development Library

Open the gz archive and there must be a * .tar archive inside it. Open * .tar, and there should be a folder inside it. Open the folder and it will contain a bunch of subfolders.

  1. Copy the contents of the lib subfolder to the MinGW lib folder. The MinGW lib folder should be in the C: \ MinGWStudio \ MinGW \ lib folder.

  2. After that, open the include subfolder in the archive and extract the folder named "SDL" into the MinGW include folder, which should be in C: \ MinGWStudio \ MinGW \ include.

Note. In some versions of SDL, there is no folder named "SDL" in the archive, including a subfolder, but just a bunch of header files. To work around this, simply create a folder named "SDL" in your MinGW include folder and copy all the header files from the archive to this folder that you made.

  1. Now take the SDL.dll from the archive (it should be inside the bin subfolder) and extract it. You are going to put this in the same directory as your exe when you compile it.

Alternatively, you can copy the SDL.dll file to C: \ WINDOWS \ SYSTEM32 so that your SDL application detects SDL.dll, even if it is not in the same directory. If you are using a 64-bit version of Windows, you need to put the DLL in C: \ Windows \ SysWOW64.

The problem with this method is that if you have multiple SDL applications that use different versions of SDL, you will have version conflicts. If you have SDL 1.2.8 in SYSTEM32 when the application uses 1.2.13, you will have problems. Typically, you want your SDL.dll in the same directory as your executable, and you always want to have SDL.dll in the same directory as exe when distributing your application.

  1. Now launch MinGW Developer Studio and start a new empty project.

  2. Go to the project settings.

  3. On the Link tab, insert: mingw32, SDLmain, SDL into the libraries field.

  4. Add the source source file to the project and paste the following code into the new source file:

//

#include "SDL/SDL.h" int main( int argc, char* args[] ) { SDL_Init( SDL_INIT_EVERYTHING ); //Start SDL SDL_Quit(); //Quit SDL return 0; } 
  1. Now compile. Save the new source file, if necessary, and make sure the SDL.dll is in the same directory as the executable. If there are no errors, you are done. Otherwise, come back and make sure that you have not missed the step.
+9
source

Source: https://habr.com/ru/post/1383574/


All Articles