【问题标题】:How to install SDL dev library so CMake can find it如何安装 SDL 开发库以便 CMake 可以找到它
【发布时间】:2015-05-06 01:07:18
【问题描述】:

我正在运行 Windows,我想将 SDL 开发文件安装在一个地方,以便 find_package(SDL) 工作。

我应该将它的一部分包含在 PATH 中还是什么?

编辑: 我创建了环境变量 SDLDIR 并将其设置为包含 lib/ 和 include/ 的目录

Cmake 输出:

cmake -G "Visual Studio 12 2013 Win64" ..
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler using: Visual Studio 12 2013 Win64
-- Check for working C compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - not found
-- Found Threads: TRUE  
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
  Could NOT find SDL (missing: SDL_LIBRARY) (found version "2.0.3")
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindSDL.cmake:199 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "E:/Code/Projects/OpenGL-SDL/build/CMakeFiles/CMakeOutput.log".
See also "E:/Code/Projects/OpenGL-SDL/build/CMakeFiles/CMakeError.log".

CMakeLists.txt:

project(OpenGL-Sample-SDL)
cmake_minimum_required(VERSION 2.8)

find_package(SDL REQUIRED)


include_directories(${SDL_INCLUDE_DIR})
link_libraries(PRIVATE ${SDL_LIBRARY})

add_executable(OpenGL-SDL main.cpp)

【问题讨论】:

  • 我将 SDLDIR 设置为包含 include 和 lib 的目录。 Cmake 找到的是 include 目录,而不是 lib 目录。
  • find_package 有错误吗?以防万一,发布错误。如果不是,请检查以下打印语句的输出:message(STATUS "SDL_LIBS=${SDL_LIBS}")
  • 它找到了 SDL 2.0.3 但由于某种原因无法定义 SDL_LIBRARY。
  • C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindPackageH andleStandardArgs.cmake:138 处的 CMake 错误(消息):找不到 SDL(缺少:SDL_LIBRARY)(找到版本“2.0.3”)调用堆栈(最近一次调用):C:/Program Files(x86)/CMake/share/cmake-3.2/Modules/FindPackageHandleStandard Args.cmake:374(_FPHSA_FAILURE_MESSAGE)C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindSDL.cmake:199 (FIND_P ACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:4 (find_package) 我认为 Cmake 在 message() 之前退出,因为找不到 SDL

标签: cmake sdl


【解决方案1】:

我在 wiki 页面上阅读了一些内容,并找到了一个解决方法。我不认为它是完美的,但现在还可以。

cmake -G "Visual Studio 12 2013 Win64" -D SDL_LIBRARY_TEMP=%SDLDIR%\lib\x64\SDL2.lib ..

虽然我遇到了另一个问题,但这正确找到了 SDL2,但我会为它创建一个新主题。

【讨论】:

    【解决方案2】:

    检查应该找到您的包的 CMace 模块的文档和源代码

    FindSDL.cmake 包含以下文档注释:

    # $SDLDIR is an environment variable that would correspond to the
    # ./configure --prefix=$SDLDIR used in building SDL.  l.e.galup 9-20-02
    

    【讨论】:

    • 很遗憾我没有自己构建 SDL,我从他们的网站下载了开发包。
    猜你喜欢
    • 2010-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-22
    • 1970-01-01
    • 1970-01-01
    • 2013-07-16
    相关资源
    最近更新 更多