C++基础 | 报错 << \Mac上使用g++编译出错“Undefined symbols for architecture x86_64:” 错误解决办法

 搞了一下午,终于找到答案了!!再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++库,问题解决!

来源

https://blog.csdn.net/eric41050808/article/details/39502231

posted @ 2019-10-03 17:10  克鲁鲁·采佩西  阅读(1100)  评论(0编辑  收藏  举报