【发布时间】:2011-12-16 03:06:26
【问题描述】:
我在尝试从 OpenCV 2.3 官方文档中编译 this tutorial 中的程序时遇到问题。我已经创建了 CMakeList.txt,就像链接中所说的那样。好吧,它没有用。
在谷歌搜索并尝试修复它之后,我已将正确的库和包含文件夹添加到 OpenCVConfig.make(在 /opt/local/share/opencv 此处)。好吧,这是我尝试制作时的输出:
$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/carlosagarie/dropbox/code/c++/opencv
$ make
Linking CXX executable teste
Undefined symbols for architecture x86_64:
"cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
_main in teste.cc.o
"cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)", referenced from:
_main in teste.cc.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [teste] Error 1
make[1]: *** [CMakeFiles/teste.dir/all] Error 2
make: *** [all] Error 2
试图找出为什么它说 ld: symbol(s) not found for architecture x86_64,我查看了我的库文件夹 (/opt/local/lib) 并使用了文件命令:
libopencv_calib3d.2.2.0.dylib: Mach-O 64-bit dynamically linked shared library x86_64
所有其他库都相同。所以,我认为这不是他们的问题。但是,为什么 ld 不工作呢?我真的不知道该怎么办。
代码与前面介绍的教程中的代码相同。我的 CMakeLists.txt 文件:
cmake_minimum_required(VERSION 2.8)
project( teste )
find_package( OpenCV REQUIRED )
add_executable( teste teste )
target_link_libraries( teste ${OpenCV_LIBS} )
提前致谢!
【问题讨论】: