Cannot build C++ code with netbeans and Cygwin

asked 2015-04-20 12:54:02 -0500

FrankC gravatar image

I was trying to build a sample C++ code in Netbeans 8.0.2 with Cygwin 1.7.35 and gcc/g++ version 4.9.2. OpenCV version is 2.4.11, installed under c:/openCV.

Regular C++ code without openCV works okay in Netbeans.

I followed instruction on http://eyalarubas.com/opencv-installa..., but cannot compile with OpenCV. First I tried to link with core library, then add highgui, then add all the rest libraries, still no luck.

What did I miss? Thank you in advance.

Source code:

#include "opencv2/opencv.hpp"
using namespace cv;

int main(int argc, char** argv) {

    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;
...
}

Errors:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/c/Users/Frank/Documents/Code/Netbeans/CppApplication_1'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x_1-Windows/cppapplication_1.exe
make[2]: Entering directory '/cygdrive/c/Users/Frank/Documents/Code/Netbeans/CppApplication_1'
mkdir -p build/Debug/Cygwin_4.x_1-Windows
rm -f "build/Debug/Cygwin_4.x_1-Windows/main.o.d"
g++    -c -g -I/cygdrive/C/opencv/build/include -MMD -MP -MF "build/Debug/Cygwin_4.x_1-Windows/main.o.d" -o build/Debug/Cygwin_4.x_1-Windows/main.o main.cpp
mkdir -p dist/Debug/Cygwin_4.x_1-Windows
g++     -o dist/Debug/Cygwin_4.x_1-Windows/cppapplication_1 build/Debug/Cygwin_4.x_1-Windows/main.o -L/cygdrive/C/opencv/build/x64/vc12/bin /cygdrive/C/opencv/build/x64/vc12/bin/opencv_core2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_highgui2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_video2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_calib3d2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_contrib2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_features2d2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_flann2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_gpu2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_imgproc2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_legacy2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_ml2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_nonfree2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_objdetect2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_ocl2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_photo2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_stitching2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_superres2411.dll /cygdrive/C/opencv/build/x64/vc12/bin/opencv_videostab2411.dll
build/Debug/Cygwin_4.x_1-Windows/main.o: In function `main':
/cygdrive/c/Users/Frank/Documents/Code/Netbeans/CppApplication_1/main.cpp:21: undefined reference to `cv::VideoCapture::VideoCapture(int)'
...

In netbeans/tools/options/C++: image description

Netbeans project properties: image description image description

edit retag flag offensive close merge delete

Comments

1.) you can't use the prebuild vs libs with mingw. you will have to get cmake, and build the opencv libraries locally, before you can go on.

2.) your linker path is wrong. after you've build the libs, it should point to opencv/build/install/lib

berak gravatar imageberak ( 2015-04-21 01:13:48 -0500 )edit

After rebuilding openCV and switching to minGW, it works great. Thank you.

FrankC gravatar imageFrankC ( 2015-04-21 11:20:13 -0500 )edit