2013-04-08 103 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前綴之後。