使用 CMake 编译时没有可用的视频设备
No available video device' when compiling with CMake
我可以使用 Makefile 编译我的代码并且它工作正常。当我尝试 运行 使用 Cmake SDL_GetError()
编译的相同代码时说:
'No available video device'
我觉得我的 CMakeLists.txt 有问题:
cmake_minimum_required(VERSION 3.10)
set(CMAKE_C_STANDARD 90)
set(CMAKE_C_STANDARD_REQUIRED True)
project(RTv1)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(SOURCES ...)
find_package(SDL2 REQUIRED)
add_executable(${PROJECT_NAME} ${SOURCES})
get_filename_component(SDL2_INCLUDE_DIR_PARENT ${SDL2_INCLUDE_DIR} DIRECTORY)
target_include_directories(${PROJECT_NAME}
PUBLIC
${SDL2_INCLUDE_DIR}
)
target_include_directories(${PROJECT_NAME}
PUBLIC
${SDL2_INCLUDE_DIR_PARENT}
)
target_include_directories(${PROJECT_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARY})
运行 Linux Mint 19.1 Tessa,项目libsdl/文件夹下自建SDL2,findSDL正常,编译成功,Clion 2019.3.3
我有一些卸载的依赖项,这有帮助:
sudo apt-get install build-essential mercurial make cmake autoconf automake \
libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \
libxss-dev libgl1-mesa-dev libdbus-1-dev libudev-dev libgles2-mesa-dev \
libegl1-mesa-dev libibus-1.0-dev fcitx-libs-dev libsamplerate0-dev \
libsndio-dev libwayland-dev libxkbcommon-dev
我可以使用 Makefile 编译我的代码并且它工作正常。当我尝试 运行 使用 Cmake SDL_GetError()
编译的相同代码时说:
'No available video device'
我觉得我的 CMakeLists.txt 有问题:
cmake_minimum_required(VERSION 3.10)
set(CMAKE_C_STANDARD 90)
set(CMAKE_C_STANDARD_REQUIRED True)
project(RTv1)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(SOURCES ...)
find_package(SDL2 REQUIRED)
add_executable(${PROJECT_NAME} ${SOURCES})
get_filename_component(SDL2_INCLUDE_DIR_PARENT ${SDL2_INCLUDE_DIR} DIRECTORY)
target_include_directories(${PROJECT_NAME}
PUBLIC
${SDL2_INCLUDE_DIR}
)
target_include_directories(${PROJECT_NAME}
PUBLIC
${SDL2_INCLUDE_DIR_PARENT}
)
target_include_directories(${PROJECT_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARY})
运行 Linux Mint 19.1 Tessa,项目libsdl/文件夹下自建SDL2,findSDL正常,编译成功,Clion 2019.3.3
我有一些卸载的依赖项,这有帮助:
sudo apt-get install build-essential mercurial make cmake autoconf automake \
libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \
libxss-dev libgl1-mesa-dev libdbus-1-dev libudev-dev libgles2-mesa-dev \
libegl1-mesa-dev libibus-1.0-dev fcitx-libs-dev libsamplerate0-dev \
libsndio-dev libwayland-dev libxkbcommon-dev