2
votes

I'm trying to use a simple c++ code with opencv:

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <iostream>

using namespace std;

int main ( int argc, char **argv )
{
 cvNamedWindow( "My Window", 1 );
 IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
 CvFont font;
 double hScale = 1.0;
 double vScale = 1.0;
 int lineWidth = 1;
 cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,
          hScale, vScale, 0, lineWidth );
 cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &font,
         cvScalar( 255, 255, 0 ) );
 cvShowImage( "My Window", img );
 cvWaitKey();
 cout << "hello world";
 return 0;
}

I've included under properties-->c/c++ build-->setting-->Cygwin c++ compiler-->Includes the absolute path of my opencv/build/include, and under Cygwin c++ linker-->libraries the path and the libraries (opencv_core246, opencv_highgui246) this time with the unix-style path /cygdrive/c/... (I read someone suggest to do this). I get this error: "make: multiple target patterns. Stop." I know the problem is related to make and multiple colons in a path... I'm on Windows 7 (x64), cygwin and Eclipse. Can anyone help me? Thank you

3

3 Answers

4
votes

Easy to solve: under project-> properties->c/c++ build->Tool chain editor, change current builder from gnu make builder to CDT Internal builder. Bugs in make from cygwin makes it generate whith the makefiles Eclipse generates

See also. http://compbiotoolbox.blogspot.co.uk/2012/01/getting-started-with-eclipse-and-cygwin.html

1
votes

In general you need to convert all windows paths to cygwin-style paths, e.g. c:\home becomes /cygdrive/c/home (the cygpath utility exists to do this translation for you).

make is complaining that it can't parse your target rules, which use a colon (:) to separate the target from its dependencies. When you use a windows path, you introduce too many colons and confuse the parser.

0
votes

I worked on this problem for far too long for how easy it was to fix. I'm working on Windows 8 with Cygwin and Eclipse for C++.

What I had to do was go to Project -> Properties -> C/C++ Build -> Tool Chain Editor and set the Current builder to CDT Internal Builder and set the Current Toolchain to MinGw GCC.

My toolchain was set to Cygwin GCC, which is what was causing the problem, because just changing the current builder didn't fix anything. Because Cygwin is the one whose recent update demands /cygwin/c/ style paths and the CDT tool isn't complying, it makes sense that switching to MinGW (which doesn't have this problem) fixed it.

Hope this helps someone else!