在Mac OS X中链接OpenCV 2.3程序Lion:找不到架构x86_64的符号 [英] Linking OpenCV 2.3 program in Mac OS X Lion: symbol(s) not found for architecture x86_64

查看:452
本文介绍了在Mac OS X中链接OpenCV 2.3程序Lion:找不到架构x86_64的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试在此计划中编译程序时遇到问题教程从OpenCV 2.3官方文档。我已经创建了CMakeList.txt像它在链接中说的。好了,它没有工作。



在搜索Google并试图解决它,我已经添加了正确的lib和include文件夹到OpenCVConfig.make在/ opt / local / share / opencv这里)。好吧,这是我尝试做出的输出:

  $ cmake。 
- 配置完成
- 生成完成
- 生成文件已写入:/ Users / carlosagarie / dropbox / code / c ++ / opencv

$ make
链接CXX可执行文件teste
架构x86_64的未定义符号:
cv :: _ InputArray :: _ InputArray(cv :: Mat const&),引用自:
_main teste.cc.o
cv :: imshow(std :: basic_string< char,std :: char_traits< char>,std :: allocator< char>> const& cv :: _ InputArray const& ,引用自:
_main in teste.cc.o
ld:没有为架构x86_64找到符号
collect2:ld返回1退出状态
make [2]: *** [teste]错误1
make [1]:*** [CMakeFiles / teste.dir / all]错误2
make:*** [all]错误2

试图找出为什么它表示为架构x86_64 找不到 ld:symbol我查看了我的库文件夹(/ opt / local / lib),并使用了文件命令:

  libopencv_calib3d.2.2.0。 dylib:Mach-O 64位动态链接共享库x86_64 

所以,我认为这不是他们的问题。但是,为什么不是ld工作他们?我真的不知道该怎么办。



代码与前面介绍的教程相同。我的CMakeLists.txt档案:

  cmake_minimum_required(VERSION 2.8)
project(teste)
find_package REQUIRED)
add_executable(teste teste)
target_link_libraries(teste $ {OpenCV_LIBS})



<提前感谢!

解决方案

我注意到你遵循2.3.x指南,但链接错误是指2.2 .0。



您使用的是哪个版本?



p>

假设 OPENCV_ROOT 设置为您的安装位置(例如/ opt / local)

  g ++ -I $ OPENCV_ROOT / include -L $ OPENCV_ROOT / lib -lopencv_core2.2.0 -lopencv_calib3d2.2.0 -c test.cpp 

如果这不起作用,您是否尝试以root身份运行 ldconfig 是在 /etc/ld.so.conf 中设置opencv库的安装位置(如果没有,您需要第一之前 ldconfig 会做任何有用的事情)?



编辑你对这些问题的更新。



编辑:

您也可以尝试添加这个到你的〜/ .profile并修复它:

  export DYLD_FALLBACK_LIBRARY_PATH = / opt / local / lib 

您是否尝试过此从第2节开始使用XCode?
的指南

I'm having a problem when trying to compile the program in this tutorial from the OpenCV 2.3 official documentation. I have created the CMakeList.txt like it's said in the link. Well, it didn't work.

After a good time searching Google and trying to fix it, I have added the correct lib and include folders to the OpenCVConfig.make (at /opt/local/share/opencv here). Well, this is the output when I try to make it:

$ 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

Trying to find out why it said ld: symbol(s) not found for architecture x86_64, I looked at my libraries folder (/opt/local/lib) and used the file command:

libopencv_calib3d.2.2.0.dylib:    Mach-O 64-bit dynamically linked shared library x86_64

The same for all the other libs. So, I assume that it's not a problem with them. But, why isn't ld working them? I really don't know what to do.

The code is the same as in the tutorial presented earlier. My CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8)
project( teste )
find_package( OpenCV REQUIRED )
add_executable( teste teste )
target_link_libraries( teste ${OpenCV_LIBS} )

Thanks in advance!

解决方案

I noticed you are following the 2.3.x guide, but the link error is referring to 2.2.0. Which version are you using?

Have you tried compiling it manually?

With something like this:

Assuming OPENCV_ROOT is set to your install location (e.g., /opt/local)

g++ -I$OPENCV_ROOT/include -L$OPENCV_ROOT/lib -lopencv_core2.2.0 -lopencv_calib3d2.2.0 -c test.cpp

If that doesn't work, have you tried running ldconfig as root? Is the install location for the opencv libraries setup in /etc/ld.so.conf (If not, you need to do this first before ldconfig will do anything useful)?

Edit you answer with updates to these questions. And, I'll try to help you with the rest.

EDIT :
You might also try adding this to your ~/.profile and see it fixes it:

export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib

Have you tried following this guide starting from Section 2 with XCode?

这篇关于在Mac OS X中链接OpenCV 2.3程序Lion:找不到架构x86_64的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆