我正在尝试使用cairo添加自定义文本OpenCV 4.2.0。
我通过here找到了有用的代码 但是当我尝试添加时,出现以下错误。
[ 50%] Linking CXX executable opencv_light
/usr/bin/ld: CMakeFiles/opencv_light.dir/opencv_light.cpp.o: undefined reference to symbol 'cairo_text_extents'
//usr/lib/x86_64-linux-gnu/libcairo.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/opencv_light.dir/build.make:148: recipe for target 'opencv_light' failed
make[2]: *** [opencv_light] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/opencv_light.dir/all' failed
make[1]: *** [CMakeFiles/opencv_light.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
然后我发现了如何使用cmake文件添加cairo。 Cairo library and Cmake
我下载了FindCaior.cmake并将以下行添加到cmake;
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(Cairo)
include_directories(${Cairo_INCLUDE_DIRS})
target_link_libraries(opencv_light ${Cairo_LIBRARIES})
但是错误代码没有改变。