What happend with my cmake code? Its about winmain@16

41 views Asked by At

I follow the tutorial on the internet but it's not working!

cmake_minimum_required(VERSION 3.10)
set(SDL2_DIR "D:/environment/")
set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include")
set(SDL2_LIB "D:/environment/SDL2/lib/x64/SDL2.lib")
set(SDL2_MAIN_LIB "D:/environment/SDL2/lib/x64/SDL2main.lib")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
project(SDL2Test)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
add_executable(SDL2Test Main.cpp)
set (SDL2_MAIN ON)
target_link_libraries(SDL2Test 
     ${SDL2_MAIN_LIB}
     ${SDL2_LIB}
)

This is the error when I use make: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain@16'

How to fix this? I have spent 3 days fixing it.enter image description here

0

There are 0 answers