Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

ld: library not found for -lippicv on Mac EL Capitan #249

Closed
mzahana opened this issue May 20, 2016 · 9 comments
Closed

ld: library not found for -lippicv on Mac EL Capitan #249

mzahana opened this issue May 20, 2016 · 9 comments

Comments

@mzahana
Copy link

mzahana commented May 20, 2016

I am trying to compile mexopencv from the terminal. I have

  • Mac OS X 10.11.14 El Capitan
  • MATLAB R2015a

I get the following error

/Applications/MATLAB_R2015a.app//bin/mex -largeArrayDims -cxx -Iinclude -I/usr/local/include/opencv -I/usr/local/include -output +cv/AGAST src/+cv/AGAST.cpp -Llib -lMxArray -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lippicv -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core  
Building with 'Xcode Clang++'.
ld: library not found for -lippicv
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What could be the problem?

I also tried the opencv support package from Mathworks, and when I run mexOpenCV mycode.cpp, I get the following error,

Building with 'Xcode Clang++'.
Error using mexOpenCV (line 120)
Undefined symbols for architecture
x86_64:
  "cv::imdecode(cv::_InputArray
  const&, int)", referenced from:
      _mexFunction in decodeUDPimg.o
ld: symbol(s) not found for
architecture x86_64
clang: error: linker command failed
with exit code 1 (use -v to see
invocation)

My code has the imdecode() function, and if I remove it, the code compiles successfully!

Any hints?

Thanks.

@kyamagu
Copy link
Owner

kyamagu commented May 21, 2016

@mzahana How did you install OpenCV, and which version? It's probably a bug in OpenCV that their pkg-config file is not setting the correct path to ippicv.

If you are using Homebrew, the easiest is to do the following.

Install OpenCV3. Optionally you might want to specify options like --with-contrib.

brew install homebrew/science/opencv3

Compile mexopencv with options to workaround the linker error.

LDFLAGS=-L/usr/local/Cellar/opencv3/3.1.0_2/share/OpenCV/3rdparty/lib/ PKG_CONFIG_OPENCV=opencv3 make -j4

Please replace the OpenCV version string above (3.1.0_2) with your installed one. You can check the current version with pkg-config --libs opencv3. LDFLAGS specifies the missing library path, and PKG_CONFIG_OPENCV specifies homebrew-specific name of OpenCV3 package.

@mzahana
Copy link
Author

mzahana commented May 21, 2016

I installed the latest download from here.
When I run the pkg-config --libs opencv3 I get the following

Package opencv3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv3' found

However, I guess I have opencv 2.4.13. I used the CMake GUI to compile opencv, and I am able to compile few opencv apps successfully.

@mzahana
Copy link
Author

mzahana commented May 21, 2016

@kyamagu I installed opencv3 as you mentioned. When I try to compile mexopencv using the options you mentioned, it gives the following error:

make: /usr/local/matlab/bin/mexext: Command not found
Makefile:77: *** "MEX extension not set".  Stop.

If I add manually MATLAB path:

LDFLAGS=-L/usr/local/Cellar/opencv3/3.1.0_3/share/OpenCV/3rdparty/lib/ PKG_CONFIG_OPENCV=opencv3 MATLABDIR=/Applications/MATLAB_R2015a.app make -j4

I get the following error:

Makefile:97: *** "OpenCV 3.x package was not found in the pkg-config search path".  Stop.

Any hints?

@kyamagu
Copy link
Owner

kyamagu commented May 21, 2016

@mzahana What does the following produce? It is a test to check if OpenCV v3.x is available via pkg-config tool. If you are not using Homebrew's OpenCV v3, you might solve the issue by simply not using PKG_CONFIG_OPENCV variable.

pkg-config --exists --atleast-version=3 opencv3
echo $?

The first error is simply a path issue. Prepending MATLABDIR as you did solves the issue.

@mzahana
Copy link
Author

mzahana commented May 21, 2016

Thanks. When I run

pkg-config --exists --atleast-version=3 opencv3
echo $?

I get:

1

@kyamagu
Copy link
Owner

kyamagu commented May 21, 2016

@mzahana Try not using opencv3 but just opencv with pkg-config. If the result is 0, you are all set.

@mzahana
Copy link
Author

mzahana commented May 21, 2016

I actually removed PKG_CONFIG_OPENCV=opencv3 and compiled mexopencv, and it compiled without errors. I hope that implies that everything is ok!

I got:

MEX completed successfully.
MEX completed successfully.
Building with 'Xcode Clang++'.
MEX completed successfully.
MEX completed successfully.

@kyamagu
Copy link
Owner

kyamagu commented May 21, 2016

@mzahana Yes, seems like you successfully compiled. Optionally you can verify installation by test. This can take a couple of minutes.

MATLABDIR=/Applications/MATLAB_R2015a.app make test

@kyamagu kyamagu closed this as completed May 21, 2016
@mzahana
Copy link
Author

mzahana commented May 21, 2016

Thanks.

I did the test, and here is what I got:

Totals:
  26 Passed, 975 Failed
  Elapsed time is 16.402672 seconds.

What does that mean?

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

No branches or pull requests

3 participants