CMakeLists.txt中使用target_link_libraries,代码如下
使用${CERES_LIBRARIES}和${CERES_LIB}结果不同,后者会引用失败,而${OpenCV_LIBS} 又是成功的
请问什么时候用 库文件名_LIB 什么时候用 库文件名_LIBS
project(CURVE)
#找ceres库并且添加头文件
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})
#找opencv库并且添加头文件
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
#add_executable要在target_link_libraries
add_executable(CURVE ceres.cpp)
#target_link_libraries中只需要添加ceres和opencv
target_link_libraries(CURVE ${OpenCV_LIBS} ${CERES_LIBRARIES})