How to link to SDL2 statically

Asked

Viewed 58 times

1

With a simple sdl project, it just 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 a SDL2.lib and Sdl2main.lib how do I use them and compile statically ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.