Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSX] Undefined symbols for architecture x86_64: #194

Open
txizzle opened this issue Sep 29, 2017 · 5 comments
Open

[OSX] Undefined symbols for architecture x86_64: #194

txizzle opened this issue Sep 29, 2017 · 5 comments

Comments

@txizzle
Copy link

txizzle commented Sep 29, 2017

Hi,

I have installed OpenCV 3.1 and Torch7. However, when I try to run luarocks install cv, it fails on libobjdetect.dylib with error:

[ 22%] Linking CXX shared library lib/libobjdetect.dylib
Undefined symbols for architecture x86_64:
  "cv::groupRectangles(std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, std::__1::vector<int, std::__1::allocator<int> >&, int, double)", referenced from:
      _groupRectangles in objdetect.cpp.o
  "cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<double, std::__1::allocator<double> >&, double, int, int, cv::Size_<int>, cv::Size_<int>, bool)", referenced from:
      _CascadeClassifier_detectMultiScale3 in objdetect.cpp.o
  "cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, std::__1::vector<int, std::__1::allocator<int> >&, double, int, int, cv::Size_<int>, cv::Size_<int>)", referenced from:
      _CascadeClassifier_detectMultiScale2 in objdetect.cpp.o
  "cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)", referenced from:
      _CascadeClassifier_detectMultiScale in objdetect.cpp.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[2]: *** [lib/libobjdetect.dylib] Error 1
make[1]: *** [CMakeFiles/objdetect.dir/all] Error 2
make: *** [all] Error 2

Alternatively, I can clone into this repository and then run: BUILD_CUDA=OFF and then luarocks make, and the installation gets a little further, but still fails at libphoto.dylib and liboptflow.dylib with error:

[ 38%] Linking CXX shared library lib/liboptflow.dylib
[ 41%] Built target videoio
[ 41%] Built target highgui
Undefined symbols for architecture x86_64:
  "cv::groupRectangles(std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, std::__1::vector<int, std::__1::allocator<int> >&, int, double)", referenced from:
      _groupRectangles in objdetect.cpp.o
  "cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<double, std::__1::allocator<double> >&, double, int, int, cv::Size_<int>, cv::Size_<int>, bool)", referenced from:
      _CascadeClassifier_detectMultiScale3 in objdetect.cpp.o
  "cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, std::__1::vector<int, std::__1::allocator<int> >&, double, int, int, cv::Size_<int>, cv::Size_<int>)", referenced from:
      _CascadeClassifier_detectMultiScale2 in objdetect.cpp.o
  "cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)", referenced from:
      _CascadeClassifier_detectMultiScale in objdetect.cpp.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[2]: *** [lib/libobjdetect.dylib] Error 1
make[1]: *** [CMakeFiles/objdetect.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Undefined symbols for architecture x86_64:
  "cv::detail::waveCorrect(std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >&, cv::detail::WaveCorrectKind)", referenced from:
      _detail_waveCorrect in stitching.cpp.o
  "cv::detail::estimateFocal(std::__1::vector<cv::detail::ImageFeatures, std::__1::allocator<cv::detail::ImageFeatures> > const&, std::__1::vector<cv::detail::MatchesInfo, std::__1::allocator<cv::detail::MatchesInfo> > const&, std::__1::vector<double, std::__1::allocator<double> >&)", referenced from:
      _detail_estimateFocal in stitching.cpp.o
  "cv::detail::FeatherBlender::createWeightMaps(std::__1::vector<cv::UMat, std::__1::allocator<cv::UMat> > const&, std::__1::vector<cv::Point_<int>, std::__1::allocator<cv::Point_<int> > > const&, std::__1::vector<cv::UMat, std::__1::allocator<cv::UMat> >&)", referenced from:
      _FeatherBlender_createWeightMaps in stitching.cpp.o
  "cv::detail::FeaturesFinder::operator()(cv::_InputArray const&, cv::detail::ImageFeatures&, std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > > const&)", referenced from:
      _FeaturesFinder_call2 in stitching.cpp.o
  "cv::detail::createLaplacePyr(cv::_InputArray const&, int, std::__1::vector<cv::UMat, std::__1::allocator<cv::UMat> >&)", referenced from:
      _detail_createLaplacePyr in stitching.cpp.o
      _detail_createLaplacePyrGpu in stitching.cpp.o
  "cv::detail::selectRandomSubset(int, int, std::__1::vector<int, std::__1::allocator<int> >&)", referenced from:
      _detail_selectRandomSubset in stitching.cpp.o
  "cv::detail::ExposureCompensator::feed(std::__1::vector<cv::Point_<int>, std::__1::allocator<cv::Point_<int> > > const&, std::__1::vector<cv::UMat, std::__1::allocator<cv::UMat> > const&, std::__1::vector<cv::UMat, std::__1::allocator<cv::UMat> > const&)", referenced from:
      _ExposureCompensator_feed in stitching.cpp.o
  "cv::detail::findMaxSpanningTree(int, std::__1::vector<cv::detail::MatchesInfo, std::__1::allocator<cv::detail::MatchesInfo> > const&, cv::detail::Graph&, std::__1::vector<int, std::__1::allocator<int> >&)", referenced from:
      _detail_findMaxSpanningTree in stitching.cpp.o
  "cv::detail::matchesGraphAsString(std::__1::vector<cv::String, std::__1::allocator<cv::String> >&, std::__1::vector<cv::detail::MatchesInfo, std::__1::allocator<cv::detail::MatchesInfo> >&, float)", referenced from:
      _detail_matchesGraphAsString in stitching.cpp.o
  "cv::detail::leaveBiggestComponent(std::__1::vector<cv::detail::ImageFeatures, std::__1::allocator<cv::detail::ImageFeatures> >&, std::__1::vector<cv::detail::MatchesInfo, std::__1::allocator<cv::detail::MatchesInfo> >&, float)", referenced from:
      _detail_leaveBiggestComponent in stitching.cpp.o
  "cv::detail::resultRoiIntersection(std::__1::vector<cv::Point_<int>, std::__1::allocator<cv::Point_<int> > > const&, std::__1::vector<cv::Size_<int>, std::__1::allocator<cv::Size_<int> > > const&)", referenced from:
      _detail_resultRoiIntersection in stitching.cpp.o
  "cv::detail::calibrateRotatingCamera(std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> > const&, cv::Mat&)", referenced from:
      _detail_calibrateRotatingCamera in stitching.cpp.o
  "cv::detail::BestOf2NearestRangeMatcher::operator()(std::__1::vector<cv::detail::ImageFeatures, std::__1::allocator<cv::detail::ImageFeatures> > const&, std::__1::vector<cv::detail::MatchesInfo, std::__1::allocator<cv::detail::MatchesInfo> >&, cv::UMat const&)", referenced from:
      _BestOf2NearestRangeMatcher_call in stitching.cpp.o
  "cv::detail::restoreImageFromLaplacePyr(std::__1::vector<cv::UMat, std::__1::allocator<cv::UMat> >&)", referenced from:
      _detail_restoreImageFromLaplacePyr in stitching.cpp.o
  "cv::detail::restoreImageFromLaplacePyrGpu(std::__1::vector<cv::UMat, std::__1::allocator<cv::UMat> >&)", referenced from:
      _detail_restoreImageFromLaplacePyrGpu in stitching.cpp.o
  "cv::detail::Blender::prepare(std::__1::vector<cv::Point_<int>, std::__1::allocator<cv::Point_<int> > > const&, std::__1::vector<cv::Size_<int>, std::__1::allocator<cv::Size_<int> > > const&)", referenced from:
      _Blender_prepare2 in stitching.cpp.o
  "cv::detail::resultTl(std::__1::vector<cv::Point_<int>, std::__1::allocator<cv::Point_<int> > > const&)", referenced from:
      _detail_resultTl in stitching.cpp.o
  "cv::detail::resultRoi(std::__1::vector<cv::Point_<int>, std::__1::allocator<cv::Point_<int> > > const&, std::__1::vector<cv::UMat, std::__1::allocator<cv::UMat> > const&)", referenced from:
      _detail_resultRoi2 in stitching.cpp.o
  "cv::detail::resultRoi(std::__1::vector<cv::Point_<int>, std::__1::allocator<cv::Point_<int> > > const&, std::__1::vector<cv::Size_<int>, std::__1::allocator<cv::Size_<int> > > const&)", referenced from:
      _detail_resultRoi in stitching.cpp.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[2]: *** [lib/libstitching.dylib] Error 1
make[1]: *** [CMakeFiles/stitching.dir/all] Error 2
Undefined symbols for architecture x86_64:
  "cv::motempl::segmentMotion(cv::_InputArray const&, cv::_OutputArray const&, std::__1::vector<cv::Rect_<int>, std::__1::allocator<cv::Rect_<int> > >&, double, double)", referenced from:
      _segmentMotion in optflow.cpp.o
ld: symbol(s) not found for architecture x86_64
clang[ 47%] Linking CXX shared library lib/libphoto.dylib
: error: linker command failed with exit code 1 (use -v to see invocation)
[ 47%] Linking CXX shared library lib/libimgcodecs.dylib
make[2]: *** [lib/liboptflow.dylib] Error 1
make[1]: *** [CMakeFiles/optflow.dir/all] Error 2
Undefined symbols for architecture x86_64:
  "cv::imreadmulti(cv::String const&, std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >&, int)", referenced from:
      _imreadmulti in imgcodecs.cpp.o
  "cv::imwrite(cv::String const&, cv::_InputArray const&, std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
      _imwrite in imgcodecs.cpp.o
  "cv::imencode(cv::String const&, cv::_InputArray const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&, std::__1::vector<int, std::__1::allocator<int> > const&)", referenced from:
      _imencode in imgcodecs.cpp.o
ld: symbol(s) not found for architecture x86_64
Undefined symbols for architecture x86_64:
  "cv::denoise_TVL1(std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> > const&, cv::Mat&, double, int)", referenced from:
      _denoise_TVL1 in photo.cpp.o
  "cv::fastNlMeansDenoising(cv::_InputArray const&, cv::_OutputArray const&, std::__1::vector<float, std::__1::allocator<float> > const&, int, int, int)", referenced from:
      _fastNlMeansDenoising2 in photo.cpp.o
  "cv::fastNlMeansDenoisingMulti(cv::_InputArray const&, cv::_OutputArray const&, int, int, std::__1::vector<float, std::__1::allocator<float> > const&, int, int, int)", referenced from:
      _fastNlMeansDenoisingMulti2 in photo.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libimgcodecs.dylib] Error 1
make[1]: *** [CMakeFiles/imgcodecs.dir/all] Error 2
make[2]: *** [lib/libphoto.dylib] Error 1
make[1]: *** [CMakeFiles/photo.dir/all] Error 2
make: *** [all] Error 2```

I saw the previous issues, but the fixes didn't work for me. Thanks!
@mlee980
Copy link

mlee980 commented Sep 30, 2017

how is your opencv installed? by port or brew or build yourself? if by port, check if you have archs='x86_64' installed:

port -v installed

if not, run:

port install opencv +universal

@txizzle
Copy link
Author

txizzle commented Oct 1, 2017

It was by anaconda: conda install -c menpo opencv. I believe my OPENCV path is set correctly, as there is no opencv path error (which I saw before, when OpenCV3.1 was not detected)

@shrubb
Copy link
Contributor

shrubb commented Oct 4, 2017

@txizzle

That's really strange. OpenCV dylibs are fetched but just some functions are missing.
I would check the OpenCV version to be 3.1.0 manually (in some cases, path error may not fire even if the path is wrong).

I'm not really familiar with Mac, but what's the output of

nm -D --defined-only <opencv-dir-that-you-give-to-luarocks>/lib/libopencv_imgcodecs.3.1.dylib | grep im

?

@mlee980
Copy link

mlee980 commented Oct 6, 2017

It is not a path issue, rather than missing libs or an opencv lib binary variant (32-bit vs 64-bit) issue:

  1. check if you have the missing libs in your opencv libs:
    /libopencv_objdetect.dylib
    /libopencv_stitching.dylib.dylib
    /libopencv_imgcodecs.dylib
    ......

  2. if they are not missing, ie. they are installed. than try this:

file /libopencv_objdetect.dylib

you should see something like these:

file libopencv_objdetect.dylib
libopencv_objdetect.dylib: Mach-O 64-bit dynamically linked shared library x86_64

if you see "32-bit" and "i386", then you have the wrong binary variant, then install the 64-bit variant.

hope this helps.

@linchakpan
Copy link

linchakpan commented Apr 21, 2020

Hi @txizzle , i am currently facing the same exact problem as you. I have installed opencv 3.1 via conda install -c menpo opencv, and have made sure that the version is osx-64: opencv3-3.1.0. However, Im also facing the problem of Undefined symbols for architecture x86_64.

Can i check with you if you have solved this installation problem? or if there is anyone who can help me with this problem, i truly appreciate it.

Installation of opencv3:
Collecting package metadata (current_repodata.json): done
Solving environment: done

Package Plan
environment location: /opt/anaconda3/envs/brandnew

added / updated specs:
- opencv3

The following NEW packages will be INSTALLED:

libblas conda-forge/osx-64::libblas-3.8.0-14_openblas
libcblas conda-forge/osx-64::libcblas-3.8.0-14_openblas
liblapack conda-forge/osx-64::liblapack-3.8.0-14_openblas
libopenblas conda-forge/osx-64::libopenblas-0.3.7-hd44dcd8_1
numpy conda-forge/osx-64::numpy-1.16.5-py27hde6bac1_0
opencv3 menpo/osx-64::opencv3-3.1.0-py27_0
tbb menpo/osx-64::tbb-4.3_20141023-0

Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

Error when installing lua cv
[ 21%] Linking CXX shared library lib/libobjdetect.dylib
Undefined symbols for architecture x86_64:
"cv::groupRectangles(std::_1::vector<cv::Rect, std::_1::allocator<cv::Rect > >&, std::__1::vector<int, std::__1::allocator >&, int, double)", referenced from:
_groupRectangles in objdetect.cpp.o
"cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::_1::vector<cv::Rect, std::_1::allocator<cv::Rect > >&, std::__1::vector<int, std::__1::allocator >&, std::__1::vector<double, std::1::allocator >&, double, int, int, cv::Size, cv::Size, bool)", referenced from:
_CascadeClassifier_detectMultiScale3 in objdetect.cpp.o
"cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::_1::vector<cv::Rect, std::_1::allocator<cv::Rect > >&, std::__1::vector<int, std::1::allocator >&, double, int, int, cv::Size, cv::Size)", referenced from:
_CascadeClassifier_detectMultiScale2 in objdetect.cpp.o
"cv::CascadeClassifier::detectMultiScale(cv::_InputArray const&, std::1::vector<cv::Rect, std::1::allocator<cv::Rect > >&, double, int, int, cv::Size, cv::Size)", referenced from:
_CascadeClassifier_detectMultiScale in objdetect.cpp.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[2]: *** [lib/libobjdetect.dylib] Error 1
make[1]: *** [CMakeFiles/objdetect.dir/all] Error 2
make: *** [all] Error 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants