kyamagu / mexopencv

Collection and a development kit of matlab mex functions for OpenCV library
http://kyamagu.github.io/mexopencv
Other
660 stars 319 forks source link

compile error #143

Closed ghost closed 9 years ago

ghost commented 9 years ago

I modified the opencv.pc file as

 Libs: -L${exec_prefix}/lib -L/usr/lib/x86_64-linux-gnu -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -lopencv_viz -ltbb -lXext -lX11 -lICE -lSM -lGL -lGLU -lrt -lpthread -lm -ldl

But the error now is as follow:

>> mexopencv.make 
make MATLABDIR="/usr/local/MATLAB/R2014a" MEXEXT=mexa64  /usr/local/MATLAB/R2014a/bin/mex -cxx -largeArrayDims -Iinclude -I/usr/local/include/opencv -I/usr/local/include   src/+cv/adaptiveThreshold.cpp -lMxArray -Llib -ltbb -lrt -lpthread -lm -ldl -L/usr/lib/x86_64-linux-gnu/ -L/usr/local/lib/  -lopencv_calib3d  -lopencv_contrib  -lopencv_core  -lopencv_features2d  -lopencv_flann  -lopencv_gpu  -lopencv_highgui  -lopencv_imgproc  -lopencv_legacy  -lopencv_ml  -lopencv_nonfree  -lopencv_objdetect  -lopencv_ocl  -lopencv_photo  -lopencv_stitching  -lopencv_superres  -lopencv_ts  -lopencv_video  -lopencv_videostab libXext libX11 libICE libSM libGL libGLU -output +cv/adaptiveThreshold
/home/bohan/Documents/software/mexopencv/libXext not found; check that you are in the correct current folder, and check the spelling of '/home/bohan/Documents/software/mexopencv/libXext'.
make: **\* [+cv/adaptiveThreshold.mexa64] Error 255

I'm not sure how to solve this problem. HELP!!!

kyamagu commented 9 years ago

I don't understand why you have libXext libX11 libICE libSM libGL libGLU in the mex arguments. Can you post the output of !pkg-config --cflags --libs opencv within matlab?

amroamroamro commented 9 years ago

@zhuangbohan: Are you sure you edited the correct opencv.pc file, not some template one in the source tree?

You want the one that pkg-config will find (either in its default search path like /usr/lib/x86_64-linux-gnu/pkgconfig/opencv.pc or manually specified by PKG_CONFIG_PATH).

ghost commented 9 years ago

@kyamagu @amroamroamro the output is

 -I/usr/local/include/opencv -I/usr/local/include  /usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so /usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_ocl.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_superres.so /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so /usr/lib/x86_64-linux-gnu/libXext.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so -ltbb -lrt -lpthread -lm -ldl  

But I have already modified the /usr/lib/x86_64-linux-gnu/pkgconfig/opencv.pc as:

prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 2.4.8
Libs: -L${exec_prefix}/lib -L/usr/lib/x86_64-linux-gnu -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -lopencv_viz -ltbb -lXext -lX11 -lICE -lSM -lGL -lGLU -lrt -lpthread -lm -ldl
Cflags: -I${includedir_old} -I${includedir_new}

I don't know why the output of pkg-config doesn't change!!

kyamagu commented 9 years ago

@zhuangbohan According to your output, you have another instance of OpenCV installed in /usr/local in addition to the packaged one at /usr/. Try to find opencv.pc under /usr/local/lib. Also make sure that your mexopencv is up-to-date.

amroamroamro commented 9 years ago

@zhuangbohan: kyamagu is right, you have a locally installed OpenCV version that is picked up by pkg-config before the one installed system-wide by the package manager.

You can get a list of paths that pkg-config searches by default using:

$ pkg-config --variable pc_path pkg-config
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig

As you can see, /usr/local/lib/.. comes before /usr/lib/.. in the search order.

Therefore, in your case you should explicitly set the one you want:

$ export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
$ pkg-config --libs opencv
jingruixiaozhuang commented 9 years ago

@kyamagu @amroamroamro Thanks a lot !! It now works!! But how can I delete the redundant one?

amroamroamro commented 9 years ago

@zhuangbohan just remove the one under /usr/local/.. if you dont need that version!

You'll want to delete the header files /usr/local/include/opencv, the libs /usr/local/lib/libopencv_* and the opencv.pc file somewhere under /usr/local/lib...

If you still have the source makefile you used to build this version, you can just cd into that directory and run make uninstall.

That way you'll end up with just OpenCV installed by apt-get.

jingruixiaozhuang commented 9 years ago

@amroamroamro
Thanks, I really learnt a lot!!