0

我一直在尝试在 Clion Windows 上设置 SDL2 和 SDL2_image(开发包)。尝试编译我的编译器后抛出错误:

C:/MinGW/bin/../lib/gcc/mingw32/5.1.0/../../../libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to WinMain@16

和很多未定义的引用。我尝试在我的和主要功能中放置-lmingw32 -lSDL2main -lSDL2 -mwindows -lSDL2_image标志,但错误不断重复。CMakeListsint main(int argc, char **argv)

我的CMakeLists.txt

cmake_minimum_required(VERSION 3.4)

#Configuration parameters of cmake
set(CMAKE_CXX_COMPILER g++)#requires g++ to be available on PATH
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(Project)

enable_language(CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 
set(CMAKE_VERBOSE_MAKEFILE TRUE) 
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

#Source files here
set(SOURCE_FILES
        textures
        include/Character.h
        src/Character.cpp
        include/TextureMenager.h
        src/TextureMenager.cpp
        include/Gameboard.h
        src/Gameboard.cpp
        include/Tile.h
        src/Tile.cpp
        include/Game.h
        src/Game.cpp
        src/main.cpp)


add_executable(Project ${SOURCE_FILES})

target_include_directories(Project PUBLIC include)

find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})
target_link_libraries(Project ${SDL2_LIBRARIES} -lmingw32 -lSDL2main -lSDL2 -mwindows ${SDL2_IMAGE_LIBRARIES}  -lSDL2_image)

我还在我的文件夹中添加了FindSDL2.cmake和。FindSDL2_image.cmakecmake

4

0 回答 0