1

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'
Community
  • 1
  • 1
ShrimpCrackers
  • 4,388
  • 17
  • 50
  • 76
  • Oh, wow. I just add them as is. How are these being referenced? Where are they located on Windows? 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) – ShrimpCrackers Apr 04 '16 at 07:15
  • Did you try to use `find_package(SDL)` for your purposes? Usually, approach with `find_package()` is easier than manually listing libraries. – Tsyvarev Apr 04 '16 at 07:59

1 Answers1

0

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)

ShrimpCrackers
  • 4,388
  • 17
  • 50
  • 76