OpenCV build undefined reference to protobuf built from source - opencv

I'm trying to build OpenCV from source. I have protobuf installed to my home directory; it was built with --enable-shared. LD_LIBRARY_PATH has $HOME/lib at the head; LIBRARY_PATH and LD_RUN_PATH are set to $LD_LIBRARY_PATH, and CPATH is set to $HOME/include. PKG_CONFIG_PATH is to $HOME/lib/pkgconfig.
Here are some relevant versions:
opencv==3.1.0
gcc==4.8.5
g++==4.8.5
python==3.5.2
protobuf==2.6.1
My CMake command is
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$HOME -D OPENCV_EXTRA_MODULES_PATH=$HOME/opencv_contrib-3.1.0/modules -D PYTHON_DEFAULT_EXECUTABLE=$HOME/bin/python -D CMAKE_PREFIX_PATH=$HOME ..
cmake succeeds and even says that it found PROTOBUF at <~>/lib/libprotobuf.so. But make fails to find it.
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::InitEmptyString()'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::empty_string_once_init_'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::internal::empty_string_'
../../lib/libopencv_dnn.so.3.1.0: undefined reference to `google::protobuf::io::CodedInputStream::BytesUntilTotalBytesLimit() const'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/opencv_test_dnn] Error 1
make[1]: *** [modules/dnn/CMakeFiles/opencv_test_dnn.dir/all] Error 2
A couple of other places mention that multiple versions of protobuf can cause problems. There is another protobuf in /lib64, but I can't remove it since I don't have root access. So I'm not sure what the workaround is.

I met the same issue recently because I installed the latest protobuf (3.1.0) and built my opencv with GCC 4.9. When I switched back to GCC 5, OpenCV 3.1 can be built successfully.
If you want to use Matlab together with OpenCV 3.1 I think you may need to downgrade your protobuf version, like protobuf-2.5.0, then you can use GCC 4.9 to rebuilt the OpenCV.

Related

openpose compilation tells undefined reference to cv::VideoCapture::VideoCapture(cv::String const&)

I have comipled caffe with GPU disabled,then
cp caffe/build/Makefile openpose/Makefile.conf
run
make all -j 6
got these errors:
-- Generating done
-- Build files have been written to: /path/to/caffe/build
CXX/LD -o ._release/examples/tutorial_thread/1_openpose_read_and_display.bin
._release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::VideoCapture(cv::String const&)'
._release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::set(int, double)'
._release/lib/libopenpose.so: undefined reference to `op::renderPartAffinityFieldGpu(float*, op::PoseModel, cv::Size_<int> const&, float const*, cv::Size_<int> const&, float, int, float)'
._release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::release()'
._release/lib/libopenpose.so: undefined reference to `op::renderBodyPartsGpu(float*, op::PoseModel, cv::Size_<int> const&, float const*, cv::Size_<int> const&, float, float)'
._release/lib/libopenpose.so: undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
can't find opencv,and I compiled latest opencv 3.2-dev from source,all opencv programs(both c++ and python) worked,so why cann't openpose find opencv?
Caffe recognized opencv actually,those reference are method that were discarded in opencv3.2 ,but are available in opencv 3.1.0 or earlier version.i had the same problem while installing 3.2 and eventualy downgrading to 3.1.0 solved the issue for me,here is a nice guide to install opencv 3.1.0 and according to
this discussion,it seems that the standard is to support opencv that are available in Ubuntu sources and i think you can't install opencv3.2 through apt-get by now,only need to build from source
With CMake installer (recommended one):
This error should never occur with the CMake installer, so I would recommend you to use the recommended installer.
With Makefile installer (deprecated one):
I have compiled caffe with GPU disabled:
You cannot disable GPU for OpenPose (nor the Caffe that OpenPose will use). I am sorry but the CPU code is not finished at all (and not expected to be finished at the moment given the very slow speed). You will have to use CUDA + cuDNN.
In order to fix the OpenCV not found problem, you need to enable in both Makefile.conf files (the one from OpenPose and Caffe), the use OpenCV 3 flag.

Using LAPACK with MINGW64

I am trying to incorporate LAPACK into a program I am trying to compile. I am currently using the msys2 toolchain with the MINGW64 gfortran compiler. I used the following process to obtain LAPACK:
To get BLAS and LAPACK together
In Msys2 64 bit environment type in:
Pacman –S mingw-w64-x86_64-cmake #gets cmake
Pacman –S git #gets git
Git clone https://github.com/msys2/MINGW-packages.git
Cd MINGW-packages/mingw-w64-lapack
Then navigate to ~/MINGW-packages/mingw-w64-lapack and open the file called PKGBUILD. Do a find and replace all from ‘RESPOSE’ to ‘RESPONSE’. Save the file and exit the text editor.
In the msys environment, type:
Makepkg-mingw
Pacman –U mingw-w64-x86_64-lapack*.pkg.tar.gz
BLAS and LAPACK are now installed.
To test lapack, do the following.
> cd ~
> wget http://www.math.ucla.edu/~wotaoyin/software/lapack_test.cpp # download
> g++ lapack_test.cpp -llapack -o lapack_test # build
> ./lapack_test # run
I then attempt to compile the program using LAPACK. My program only calls sgetrf and sgetrs. However, when I compile I receive the following errors:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetrf.f.obj):(.text+0x43a): undefined reference to `strsm_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetrf.f.obj):(.text+0x524): undefined reference to `sgemm_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetrs.f.obj):(.text+0x159): undefined reference to `strsm_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetrs.f.obj):(.text+0x1c5): undefined reference to `strsm_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetrs.f.obj):(.text+0x340): undefined reference to `strsm_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetrs.f.obj):(.text+0x3ac): undefined reference to `strsm_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetf2.f.obj):(.text+0x1c3): undefined reference to `isamax_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetf2.f.obj):(.text+0x212): undefined reference to `sswap_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetf2.f.obj):(.text+0x36c): undefined reference to `sger_'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../lib\liblap
ack.a(sgetf2.f.obj):(.text+0x3ca): undefined reference to `sscal_'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile.all:20: avl] Error 1
What am I missing in linking liblapack.a?
My command is:
gfortran -m64 -o avl avl.o aoper.o amode.o amass.o asetup.o amake.o ainput.o
aoutput.o aero.o atrim.o atpforc.o aic.o cdcl.o airutil.o autil.o aplotvl.o aplo
ttp.o aplotmd.o limits.o pltops.o hidden.o plsubs.o userio.o plutil.o arrow3d.o
getvm.o matrix.o spline.o sgutil.o second.o -static ../plotlib/libPlt_mingwSP.a
../eispack/libeispack.a -lgdi32 -luser32 -lblas -llapack
I wanted to answer my own question as I believe I found the error.
First, it looks like these calls are related to BLAS. So I needed to add -lblas to compile call. However, I initially tried this to no effect and then called -lblas AFTER the -llapack call and it worked.
Here is another solution. Get the code from https://www.gnu.org/software/gcc/testing/testing-lapack.html. Download by clicking on the link lapack.tgz. The make.inc file is already setup (you may have to rename it), so all you have to do is run make.
I went down several blind alleys before getting to this point. I tried them in google order.
http://icl.cs.utk.edu/lapack-for-windows/lapack/#libraries gave me four files which are not compatible with gfortran. Maybe I missread the webpage, but at any rate, if the compatible libraries are there, I didn't find them.
https://packages.msys2.org/package/mingw-w64-x86_64-lapack - downloading and unpacking the tar file gives files which don't work with gfortran.
http://www.netlib.org/lapack/ - download and unpack lapack-3.9.0.tar.gz. This is designed to be made on a wide variety of systems, but doesn’t include mingw gfortran. The make files and other scripts are more complicated than I wanted to tackle. One solution is given at https://gcc.gnu.org/wiki/LAPACK%20on%20Windows, but it is 8 years old and would have to be updated.
You know, it is no wonder everyone has abandoned Fortran when it is this difficult do use these standard libraries. The same stuff is built into Python, Matlab or Octave

Error installing OpenCV on Ubuntu 16.04

I have being trying to install OpenCV on Ubuntu 16.04 unsing several tutorials and i always end up with an error. This is the last one i've got following this tutorial:
https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-OpenCV-3.1-Installation-Guide
What can i do?
[ 48%] Linking CXX executable ../../bin/opencv_test_viz
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadDirectory#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFIsTiled#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFDefaultStripSize#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadTile#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFWriteScanline#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `_TIFFfree#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFGetField#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFScanlineSize#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFTileSize#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFClose#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFClientOpen#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFGetFieldDefaulted#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFNumberOfDirectories#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFOpen#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadRGBAImage#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetField#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetWarningHandler#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetErrorHandler#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `_TIFFmalloc#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetDirectory#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadScanline#LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFNumberOfTiles#LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
modules/viz/CMakeFiles/opencv_test_viz.dir/build.make:236: recipe for target 'bin/opencv_test_viz' failed
make[2]: *** [bin/opencv_test_viz] Error 1
CMakeFiles/Makefile2:3306: recipe for target 'modules/viz/CMakeFiles/opencv_test_viz.dir/all' failed
make[1]: *** [modules/viz/CMakeFiles/opencv_test_viz.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
I followed the same tutorial for install opencv and I had the same problem.
This works for me:
sudo apt-get autoremove libtiff5-dev
sudo apt-get install libtiff5-dev
Enter the opencv directory.
cd build/ (I guess that is already created,otherwise create it)
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make
then continue with the tutorial.
According to this, OpenCV needs libtiff4, which Ubuntu has dropped, i.e. the package that replaced it is libtiff5-dev.
As a temporary workaround you can specify -DBUILD_TIFF=ON on cmake when configuring, in order to build the libtiff4 version that is distributed with OpenCV.
This worked for me in Ubuntu 16.04, with OpenCV 3.2.1.
Looks like you need to install/reinstall libpng.
Try make clean ,and then again execute the make command. Generally after one failure if you try the make command without cleaning the earlier installation, you get errors.
I had similar issue. I was building openCV 3.3.0 together with opencv_contrib repository. It turned out that including the flag -D BUILD_TIFF=ON with cmake command resolved the issue as pointed out by gevang already.
Ps.: Since I'm only acknowledging the solution provided by gevang, this should rather a be comment instead of an answer, but I'm missing the corresponding rights. Sorry for that.

Linker errors in compiling a simple pthread code under MingW

I am trying to compile a single c++ source file test.cpp, which has a very simple code which demonstrates pthread_create(); pthread_cond_signal/pthread_cond_wait() functionality.
I have installed Mingw / Ansys on Windows XP where I am working. In the MingW prompt I do:
g++ -IC:/MinGW/include/ -lpthread test.cpp
//-IC:/MinGW/include to get pthread.h
//-LC:/MinGW/bin to get pthreadGC2.dll
The cpp includes pthread.h as:
#include <pthread.h>
But this gave me multiple linker undefined reference errors to all pthread library functions.
What am I doing wrong here. Is it possible to build a pthread code on MingW environment on windows or not?
How to resolve this errors?
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x23): undefined reference to `_imp__pthread_mutex_lock'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x67): undefined reference to `_imp__pthread_cond_signal'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x75): undefined reference to `_imp__pthread_mutex_unlock'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x98): undefined reference to `_imp__pthread_exit'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0xbc): undefined reference to `_imp__pthread_mutex_lock'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0xe8): undefined reference to `_imp__pthread_cond_wait'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x10f): undefined reference to `_imp__pthread_mutex_unlock'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x135): undefined reference to `_imp__pthread_exit'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x153): undefined reference to `_imp__pthread_attr_init'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x169): undefined reference to `_imp__pthread_mutex_init'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x17f): undefined reference to `_imp__pthread_attr_setdetachstate'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x195): undefined reference to `_imp__pthread_cond_init'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x1bc): undefined reference to `_imp__pthread_create'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x1e3): undefined reference to `_imp__pthread_create'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x201): undefined reference to `_imp__pthread_join'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x21f): undefined reference to `_imp__pthread_join'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x239): undefined reference to `_imp__pthread_mutex_destroy'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x247): undefined reference to `_imp__pthread_cond_destroy'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x255): undefined reference to `_imp__pthread_attr_destroy'
C:\DOCUME~1\ADESHP~1\LOCALS~1\Temp\ccUQhu7D.o:pthread_cond.c:(.text+0x263): undefined reference to `_imp__pthread_exit'
collect2: ld returned 1 exit status
You need to specify the library on the gcc/g++ command line after the files that depend on the library. So try:
g++ -IC:/MinGW/include/ test.cpp -lpthread
I kicked myself when I stumbled on the answer (it's kind of a FAQ for libraries and gcc). For most gcc options order doesn't matter, but for libraries it's critical.
You should not have to specify the library path if the pthread library came with your MinGW distribution (as it seems is the case for you). Also, remember that the command line above will produce an a.exe executable; pass -o test.exe to avoid that.

OpenCV build error

If this is not out of place here, would like to know about the source and fix for an error I get when I am building OpenCV under Cygwin (On Windows 7 64 bit).
I have Cygwin installed with MingW- pthread pacgae installed in that cygwin installation.
I have downloaded OpenCV ver. 2.3.1 source package.
EDIT:
After some tweaks, and changes to build process OpenCV builds fine now.
But when I compile a simple test openCV code(C source code), as below it gives lot of linker errors of undefined references to many basic openCV functions. I tried setting LD_LIBRARY_PATH correctly but still errors persit:
cc -L/usr/local/lib -I/usr/local/include/opencv2 -/usr/local/include/opencv -lop encv_imgproc -lopencv_highgui -lopencv_video -lopencv_calib3d test1.c -o test_op encv
cc: unrecognized option '-/usr/local/include/opencv'
/tmp/ccfEqFK0.o:test1.c:(.text+0x9dd): undefined reference to `_cvFree_'
/tmp/ccfEqFK0.o:test1.c:(.text+0xa4e): undefined reference to `_cvFree_'
/tmp/ccfEqFK0.o:test1.c:(.text+0xb44): undefined reference to `_cvGetRows'
/tmp/ccfEqFK0.o:test1.c:(.text+0xb6f): undefined reference to `_cvGetCols'
/tmp/ccfEqFK0.o:test1.c:(.text+0xb82): undefined reference to `_cvReleaseMat'
/tmp/ccfEqFK0.o:test1.c:(.text+0xcd2): undefined reference to `_cvAddS'
/tmp/ccfEqFK0.o:test1.c:(.text+0x1137): undefined reference to `_cvRead'
/tmp/ccfEqFK0.o:test1.c:(.text+0x11e1): undefined reference to `_cvLoadImage'
/tmp/ccfEqFK0.o:test1.c:(.text+0x129d): undefined reference to `_cvCreateImage'
/tmp/ccfEqFK0.o:test1.c:(.text+0x12dd): undefined reference to `_cvResize'
/tmp/ccfEqFK0.o:test1.c:(.text+0x12f1): undefined reference to `_cvNamedWindow'
/tmp/ccfEqFK0.o:test1.c:(.text+0x1305): undefined reference to `_cvNamedWindow'
'
/tmp/ccfEqFK0.o:test1.c:(.text+0x13ad): undefined reference to `_cvDestroyWindow
... ... Many more undefined references.
'
collect2: ld returned 1 exit status
Makefile:10: recipe for target `test_opencv' failed
make: *** [test_opencv] Error 1
EDIT
Below message is still there, but it is not an error but a message during build process.
*Then while building OpenCV under cygwin, when I do make , it gives a error message
c++: unrecognized option '-pthread'
[ 36%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_sunras.o*
and for many other files i see the same error c++: unrecognized option '-pthread'
I would like to know if anyone has experience in building openCV under Cygwin , how to get OpenCV going under cygwin? . Now I know there is windows setup for OpenCV but that is not what is an option to me.
Your cmd line arguments has a few problems. It seems that it was not fully pasted in your question (some indentation problems suggests so).
One obvious mistake can be easily identified since CC is telling you about it: cc: unrecognized option '-/usr/local/include/opencv':
When adding headers directories in the command line, you must specify each of them with -I. Notice how you failed to do so with: -/usr/local/include/opencv. It should be -I/usr/local/include/opencv
You also seem to be missing -lopencv_core in the cmd-line
In the future, use pkg-config (if its properly configured) to help you include opencv headers and libraries:
cc test.c -o test_op `pkg-config --cflags --libs opencv` -lop
Thanks for pointers:
What I found was the problem was as follows:
In my Makefile of my openCV test app I was linking with the import libraries (*.a). Which was the problem.
Problematic Makefile was linking against files
-l:/usr/local/lib/libopencv_core.dll.a ...etc...
I changed that to link with actual dll libs, then it worked(linked) fine, w/o any errors as above.
Changes Makefile looks:
LIBS = -l:/usr/local/bin/cygopencv_core-2.3.dll -l:/usr/local/bin/cygopencv_imgproc-2.3.dll -l:/usr/local/bin/cygopencv_highgui-2.3.dll -l:/usr/local/bin/cygopencv_video-2.3.dll -l:/usr/local/bin/cygopencv_calib3d-2.3.dll

Resources