Undefined reference to SDL_Init (CodeBlocks)

I wanted to teach myself SDL, but in the first attempt I ran into a rather unpleasant problem. I did some research and found out that I first need CodeBlocks to know where the library is. Firstly, I have a 64 byte OS.

Just as I read, I put things in:

Project → Linker settings (direct links to DLL files, I chose x64, of course) and "-lmingw32 -lSDL2main -lSDL2" in "other linker options". This puzzles me a bit, but replacing 32 with 64 raises another error, so I saved it that way.

Project → Search Directories:

-> Compiler: link to /include folder with header files
-> Linker: link to /lib folder with .dll files

I also made sure that these things are visible after clicking on the project itself and selecting "build options".

Did I forget something?

+4
source share
1 answer

You must have "compatible" versions of libraries and compilers - I mean architecture, 32 or 64 bits. I see that you are using 32-bit MinGW, so always use 32-bit SDL libraries.

It was about choosing a version of the SDL library. As for your main question, are you following all the steps to configure SDL2 in CodeBlocks correctly?

  • Search Directories> Compiler> / include
  • Directory Search> Linker> / lib ( This folder should contain .lib files, not .dlls )
  • Linker Settings> Other Linker Settings: -lmingw32 -lSDL2main -lSDL2

(graphic - in my opinion, the best on the Internet - the tutorial is here )

DLL. .lib, , SDL.

0

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


All Articles