2013-04-08 60 views
1

昨天我做了一个“CMakeLists.txt”文件,其中包含以下内容。包括OpenCV与CMake Linux

cmake_minimum_required(VERSION 2.8) 
project(HMirror) 
find_package(OpenCV REQUIRED) 
add_executable(HMirror HMirror.cpp) 
target_link_libraries(HMirror ${OpenCV_LIBS}) 

它工作得很好,我没有改变任何东西......(真的!!!!)

今天,我想一些额外的功能添加到我的代码,我得到了下面的输出在我的Linux贝壳。

HMirror.cpp:(.text+0x56): undefined reference to `cv::imread(std::string const&, int)' 
HMirror.cpp:(.text+0x191): undefined reference to `cv::namedWindow(std::string const&, int)' 
HMirror.cpp:(.text+0x1f1): undefined reference to `cv::namedWindow(std::string const&, int)' 
HMirror.cpp:(.text+0x268): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)' 
HMirror.cpp:(.text+0x2df): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)' 

我还没有改变图书馆的目的地,并没有改变自昨天以来的代码。所以我想知道为什么它似乎没有工作了。

+1

如果你能提供导致这些错误的链接器命令会有帮助 - 使用类似'make VERBOSE = 1'的东西 – 2013-04-09 06:10:45

回答

2

试着明确写出链接的库。在Linux上,这将是opencv_coreopencv_highguiopencv_imgproc等..

如果您编译从源代码库,该库的名称将在/usr/local/lib发现,从名字中减去的lib前缀之后。