ShrimpCrackers
ShrimpCrackers

Reputation: 4552

Linking SDL2 libraries with CMake

I am trying to get a simple SDL app running using CLion IDE (mingw-w64, CMake).

In this question it says to link the following libraries in order to get SDL2 working with mingw.

-lmingw32 -lSDL2main -lSDL2 -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid

I know what the first 3 are and how to find and link them using CMake. I have no idea how to include the rest of the libraries because I don't know where they are located or how to get access to them.

Also, is there a difference between libSDL2 and lSDL2? SDL provides libs named libSDL2.a, but I always see in examples that it is spelled lSDL2.

Why do the lazyfoo tutorials say you only need lmingw32, lSDL2main, and lSDL2? It's what I currently am linking in CMake, but I'm getting undefined references to things like

SDL_windowskeyboard.c:617: undefined reference to `ImmGetIMEFileNameA'

Upvotes: 1

Views: 1310

Answers (1)

ShrimpCrackers
ShrimpCrackers

Reputation: 4552

The solution was to just add the libraries as-is. My example would have been:

target_link_libraries(Dark_Knights ${MINGW32_LIBRARY} ${SDL_MAIN_LIBRARY} ${SDL_LIBRARY} -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid)

Upvotes: 0

Related Questions