我下载了zbar库,并在我的主目录中克隆了opencv-zbar个repo。然后我运行了以下命令$cmake .
,它给出了我的错误
-- Could NOT find ZBAR (missing: ZBAR_LIBRARIES ZBAR_INCLUDE_DIR) 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: ZBAR_LIBRARIES linked by target "zbar_opencv" in directory /home/surabhi/opencv-zbar -- Configuring incomplete, errors occurred! See also "/home/surabhi/opencv-zbar/CMakeFiles/CMakeOutput.log".
然后我在我的CMakeCache.txt中做了两处更改,如下所示
//Path to a file.
ZBAR_INCLUDE_DIR:PATH=/usr/include/zbar
//Path to a library.
ZBAR_LIBRARIES:FILEPATH=/usr/lib/libzbar.so
因为设置为NOTFOUND
。
然后它没有给我任何错误
-- Found ZBAR: /usr/lib/libzbar.so -- Configuring done -- Generating done -- Build files have been written to: /home/surabhi/opencv-zbar
但是当我运行make
它给出错误:
fatal error: zbar.h: No such file or directory #include <zbar.h> ^ compilation terminated.
我不明白为什么我会在运行cmake
时发现找到ZBAR 时出现此错误。
提前致谢
答案 0 :(得分:1)
您需要在 CMakeLists.txt 中的某处实际使用include dirs,以便CMake知道您确实想要使用这些包含路径。
示例:
include_directories(${ZBAR_INCLUDE_DIR})
或者更现代,推荐的方式:
target_include_directories(zbar_opencv PRIVATE ${ZBAR_INCLUDE_DIR})