今天运行了用CLion一下视觉SLAM十四讲的ch5的部分代码,本以为能顺顺利利的跑起来,但结果让人意想不到。出现了大面积的报错,说相应的函数没有定义应用。
我百思不得其解,于是查看了CMAKELISTS,发现原来是这一部分出了问题,于是将这一部分的代码进行了增加。主要原因是缺少相应的链接,找不到OPENCV函数库。
可以在将上面代码整体换成如下代码。
cmake_minimum_required( VERSION 2.8 )
project(imageBasics)
set( CMAKE_CXX_FLAGS "-std=c++11 -O3")
find_package(OpenCV)
include_directories(${OpenCV})
add_executable(imageBasics imageBasics.cpp)
# 链接OpenCV库
target_link_libraries(imageBasics ${OpenCV_LIBS})
add_executable(undistortImage undistortImage.cpp)
# 链接OpenCV库
target_link_libraries(undistortImage ${OpenCV_LIBS})