SDL2/_real_SDL_config.h: 没有那个文件或目录

SDL2/_real_SDL_config.h: No such file or directory

我一直在尝试在 WSL (Ubuntu) 上设置 SDL2,并使用 cmake 和 mingw 交叉编译为 windows。我 运行 遇到了这个问题,它试图自己编译库文件失败:

                 from /usr/include/SDL2/SDL_main.h:25,
                 from /usr/include/SDL2/SDL.h:32,
                 from /mnt/c/users/user/repos/project/final.cpp:5:
/usr/include/SDL2/SDL_config.h:4:10: fatal error: SDL2/_real_SDL_config.h: No such file or directory
    4 | #include <SDL2/_real_SDL_config.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

这是我的CmakeLists.txt

project(name)
set(CMAKE_CXX_STANDARD 14)            # Enable c++14 standard
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${name_SOURCE_DIR}/CMakePath")
SET(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)

set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)


set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)t
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(SOURCE_FILES final.cpp Soldier.cpp TilesEnum.cpp)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --static -std=c++0x -o test")

#add_executable(${PROJECT_NAME} src/test.cpp)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})

find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)

include_directories(${SDL2_INCLUDE_DIR}
                    ${SDL2_IMAGE_INCLUDE_DIR}
                    ${SDL2_TTF_INCLUDE_DIR})
target_link_libraries(name ${SDL2_LIBRARY}
                             ${SDL2_IMAGE_LIBRARIES}
                             ${SDL2_TTF_LIBRARIES})

set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc")

到目前为止,我的 运行 理论是我安装了错误的库,但这并不能解释为什么它根本无法编译。我很迷茫。我找不到与此特定问题相关的任何内容,请 link 如果有类似的问题请告诉我。

这个CMake文件有很多错误,有很多重复的代码。 Tsyvarev 的评论帮助解决了这个问题。