我刚刚通过apt-get安装了libsdl2-image-dev,这是我的“ dpkg -L libsdl2-image-dev”命令的结果:
$ dpkg -L libsdl2-image-dev
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libsdl2-image-dev
/usr/share/doc/libsdl2-image-dev/copyright
/usr/share/doc/libsdl2-image-dev/examples
/usr/share/doc/libsdl2-image-dev/examples/showimage.c
/usr/include
/usr/include/SDL2
/usr/include/SDL2/SDL_image.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libSDL2_image.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/SDL2_image.pc
/usr/share/doc/libsdl2-image-dev/changelog.Debian.gz
/usr/lib/x86_64-linux-gnu/libSDL2_image.so
/usr/lib/x86_64-linux-gnu/libSDL2_image-2.0.so
但是,cmake中的“ find_package(SDL2_IMAGE REQUIRED)”抱怨:
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!
有人知道如何解决它吗?谢谢!
答案 0 :(得分:0)
对于 x64 LINUX
安装 sdl2 镜像库
apt install libsdl2-image-dev
在 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)