How to link SDL2 statically

1

With a simple sdl project, it only shows an empty window. I'm using the following CMake (in CLion):

cmake_minimum_required(VERSION 3.3)
project(AprendendoCpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(SDL2_INCLUDE_DIR C:/Linguagens/Cpp/Libs/SDL/x86_64-w64-mingw32/include/SDL2)
set(SDL2_LIBRARY C:/Linguagens/Cpp/Libs/SDL/x86_64-w64-mingw32/lib)
include_directories(${SDL2_INCLUDE_DIR})
link_directories(${SDL2_LIBRARY})
set(SOURCE_FILES main.cpp)
add_executable(AprendendoCpp ${SOURCE_FILES})
target_link_libraries(AprendendoCpp  -lSDL2 -lSDL2main)

It compiles normally, but the EXE is depending on a dll, SDL2.dll. In source there are SDL2.lib and SDL2main.lib how do I use them and compile statically?

    
asked by anonymous 19.05.2016 / 19:06

0 answers