【问题标题】:Installed library cannot be found by CMakeCMake 找不到已安装的库
【发布时间】:2013-09-06 05:20:30
【问题描述】:

我在运行 CMake 时遇到以下问题。

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
DIRECTFB_INCLUDE_DIR (ADVANCED)
  used as include directory in directory /u/menie482/workspace/AtariTEXPLORE
  used as include directory in directory /u/menie482/workspace/AtariTEXPLORE/rl_common
  used as include directory in directory /u/menie482/workspace/AtariTEXPLORE/rl_agent
  used as include directory in directory /u/menie482/workspace/AtariTEXPLORE/rl_env
DIRECTFB_LIBRARY (ADVANCED)
  linked by target "experiment" in directory /u/menie482/workspace/AtariTEXPLORE

其实我在运行的时候已经检查过DirectFB已经安装好了

locate libdirectfb

那么,我该怎么做才能让 CMake 知道 DIrectFB 在哪里?一个不方便的限制是我不能在这台机器上执行 sudo..

谢谢!

【问题讨论】:

    标签: cmake directfb


    【解决方案1】:

    我猜,您正在尝试在 CMakeLists.txt 文件中使用类似 find_package(directfb) 的内容。只有当你有 /usr/share/cmake/Modules/directfb.cmake (Ubuntu 12.04) 时才能运行。

    我的第二个猜测是您在 CMakeLists.txt 文件中使用了类似 pkg_module(directfb) 的东西。只有当你在某个地方有 directfb.pc 时才能运行。

    否则
    你在哪里设置变量 DIRECTFB_INCLUDE_DIR 和 DIRECTFB_LIBRARY。

    作为替代步骤,请尝试使用find_library()。您必须提供 libdirectfb.so 的确切路径并执行类似

    的操作

    find_library(DIRECT_FB NAMES directfb PATHS path/directfb.so )
    target_link_libraries(MyLibraryOrMyExecutable ${DIRECT_FB})

    【讨论】: