0

I have a cpp file which works fine with g++ before upgrading these stuff. Currently, when running : g++ -I/usr/local/Cellar/opencv3/3.1.0_1/include -stdlib=libc++ bs.cpp -o bs Results are following:

Undefined symbols for architecture x86_64:
"cv::namedWindow(cv::String const&, int)", referenced from:
  _main in bs-df9f1a.o
"cv::VideoCapture::read(cv::_OutputArray const&)", referenced from:
  processVideo(char*) in bs-df9f1a.o
"cv::VideoCapture::release()", referenced from:
  processVideo(char*) in bs-df9f1a.o
"cv::VideoCapture::VideoCapture(cv::String const&)", referenced from:
  processVideo(char*) in bs-df9f1a.o
"cv::VideoCapture::~VideoCapture()", referenced from:
  processVideo(char*) in bs-df9f1a.o
"cv::destroyAllWindows()", referenced from:
  _main in bs-df9f1a.o
"cv::createBackgroundSubtractorMOG2(int, double, bool)", referenced from:
  _main in bs-df9f1a.o
"cv::Mat::deallocate()", referenced from:
  cv::Mat::release() in bs-df9f1a.o
"cv::Mat::copySize(cv::Mat const&)", referenced from:
  cv::Mat::operator=(cv::Mat const&) in bs-df9f1a.o
"cv::String::deallocate()", referenced from:
  cv::String::~String() in bs-df9f1a.o
"cv::String::allocate(unsigned long)", referenced from:
  cv::String::String(char const*) in bs-df9f1a.o
  cv::String::String(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in bs-df9f1a.o
"cv::imread(cv::String const&, int)", referenced from:
  processImages(char*) in bs-df9f1a.o
"cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from:
  processVideo(char*) in bs-df9f1a.o
  processImages(char*) in bs-df9f1a.o
"cv::putText(cv::_InputOutputArray const&, cv::String const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)", referenced from:
  processVideo(char*) in bs-df9f1a.o
  processImages(char*) in bs-df9f1a.o
"cv::waitKey(int)", referenced from:
  processVideo(char*) in bs-df9f1a.o
  processImages(char*) in bs-df9f1a.o
"cv::fastFree(void*)", referenced from:
  cv::Mat::~Mat() in bs-df9f1a.o
"cv::rectangle(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)", referenced from:
  processVideo(char*) in bs-df9f1a.o
  processImages(char*) in bs-df9f1a.o
"cv::VideoCapture::get(int) const", referenced from:
  processVideo(char*) in bs-df9f1a.o
"cv::VideoCapture::isOpened() const", referenced from:
  processVideo(char*) in bs-df9f1a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I do not know how to solve this problem, it's not related to source code or include, it's related to the linker. I see the post:C++ linking error after upgrading to Mac OS X 10.9 / Xcode 5.0.1 Which really sounds reasonable, but I do not know how to add -stdlib=libstdc++ to the linking command. ?

Hope sb could help. Thanks in advance.

Community
  • 1
  • 1
printemp
  • 869
  • 1
  • 10
  • 33

0 Answers0