使用CMake编译时没有可用的视频设备

问题描述 投票:0回答:1

我可以使用Makefile编译我的代码,它可以正常工作。当我尝试运行使用Cmake编译的相同代码时,SDL_GetError()说:

'没有可用的视频设备'

我认为我的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

c linux cmake sdl-2 clion
1个回答
2
投票

我有一些已卸载的依赖项,这有所帮助:

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
© www.soinside.com 2019 - 2024. All rights reserved.