Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我已经通过apt get安装了libsdl2映像开发程序,但cmake找不到它_Cmake - Fatal编程技术网

我已经通过apt get安装了libsdl2映像开发程序,但cmake找不到它

我已经通过apt get安装了libsdl2映像开发程序,但cmake找不到它,cmake,Cmake,我刚刚通过apt get安装了libsdl2 image dev,下面是我的“dpkg-L libsdl2 image dev”命令的结果: 但是,cmake中的“find_包(需要SDL2_映像)”抱怨: CMake Error at CMakeLists.txt:34 (find_package): By not providing "FindSDL2_IMAGE.cmake" in CMAKE_MODULE_PATH this project has asked CMake to

我刚刚通过apt get安装了libsdl2 image dev,下面是我的“dpkg-L libsdl2 image dev”命令的结果:

但是,cmake中的“find_包(需要SDL2_映像)”抱怨:

CMake Error at CMakeLists.txt:34 (find_package):
  By not providing "FindSDL2_IMAGE.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "SDL2_IMAGE", but CMake did not find one.

  Could not find a package configuration file provided by "SDL2_IMAGE" with
  any of the following names:

    SDL2_IMAGEConfig.cmake
    sdl2_image-config.cmake

  Add the installation prefix of "SDL2_IMAGE" to CMAKE_PREFIX_PATH or set
  "SDL2_IMAGE_DIR" to a directory containing one of the above files.  If
  "SDL2_IMAGE" provides a separate development package or SDK, be sure it has
  been installed.


-- Configuring incomplete, errors occurred!

有人知道怎么修吗?谢谢

适用于x64 LINUX的

安装sdl2映像库

apt安装libsdl2映像开发人员
在cmake configs文件夹
/usr/lib/x86_64-linux-gnu/cmake/sdl2_image/sdl2_image-config.cmake中创建一个文件

把这个放进去

set(prefix "/usr") 
set(exec_prefix "${prefix}")
set(libdir "${prefix}/lib/x86_64-linux-gnu")
set(SDL2_IMAGE_PREFIX "/usr")
set(SDL2_IMAGE_EXEC_PREFIX "/usr")
set(SDL2_IMAGE_INCLUDE_DIRS "${prefix}/include/SDL2_image")
set(SDL2_IMAGE_LIBRARIES "-lSDL2_image")
然后添加到
CMakeLists.txt
以下内容

find_package(SDL2_image REQUIRED)
target_link_libraries(app SDL2_image)

错误消息中没有列出任何文件(
FindSDL2_IMAGE.cmake
SDL2_IMAGEConfig.cmake
SDL2_IMAGE-config.cmake
)。如果您遵循,那么它将说明文件
FindSDL2\u IMAGE.cmake
,您必须创建该文件,并通过
cmake\u模块路径
variable.Solved使其可搜索。谢谢
find_package(SDL2_image REQUIRED)
target_link_libraries(app SDL2_image)