mac上使用g++编译出错“Undefined symbols for architecture x86_64:” 错误解决办法

欢迎加入“OpenCV学习交流”QQ群:290295071        

搞了一下午,终于找到答案了!!再Mac上使用自带的g++编译使用opencv编写的图像代码,在使用图像数据结构时,使用IplImage和CvMat数据类型进行简单的加载、显示图像和两种数据的相互转换都没有错误,但只要使用Mat数据结构就出现下面的错误:

Undefined symbols for architecture x86_64:\
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long)", referenced from:\
      _main in main.o\
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:\
      _main in main.o\
  "std::terminate()", referenced from:\
      ___clang_call_terminate in main.o\
  "___cxa_begin_catch", referenced from:\
      ___clang_call_terminate in main.o\
  "___gxx_personality_v0", referenced from:\
      _main in main.o\
      Dwarf Exception Unwind Info (__eh_frame) in main.o\
ld: symbol(s) not found for architecture x86_64\
clang: error: linker command failed with exit code 1 (use -v to see invocation)\
make: *** [main] Error 1\

想了很多办法,终于看到有人提示:编译选项添加-lstdc++,即使用标准C++库,问题解决!

-------------------------------------------------------------------------------------------------------------------------

机器视觉群:454254462 ,欢迎加入,进行算法研究!
AR/VR群:244751474 ,欢迎加入,进行项目讨论!

评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值