1

A little description about my environment: DevCpp 4.9.9.2 with OpenCV 2.3.1 on Windows Vista Home Premium SP1 32-bit

About my project - my project's .dev (FirstCVproj.dev) file is in c:...\Desktop\proj\openCV\ and the program i'm trying to compile "facedetect.cpp" is in c:\opencv\samples\c

The OpenCV compiler configuration in the tools->compilers in DevCpp is:

Compiler commands

-L"C:\opencv\build\x86\mingw\lib" -llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231

Linker commands

-llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231

Libraries directory: opencv\build\x86\mingw\lib

Binaries directory: opencv\build\x86\mingw\bin

Include directories: all the include folders in opencv folder (under the \build and the main folder)

So before I decided to post here, i was having the problems stated here and in that order:

libgcc_s_dw2_1.dll not found. Try reinstalling the application

Program can't find libgcc_s_dw2-1.dll

libstdc++-6.dll not found. Try reinstalling the application libstdc++-6.dll not found

Because using -static or -static-libgcc or -static-libstdc++ in linker command line options box did not work for me, i copied the first dll file to my project directory from some other directory in my system where i found it (and nowhere in mingw32 folder in C:\DevCpp) and downloaded the second one off the net, my project stopped giving run-time errors like "FirsCVProj has stopped working. Contact the application vendor for support" or ".dll was not found"

But it became worse, because at runtime, i did see the command output window of the program i was compiling in my project, but that just appeared for like a fraction of a second!

I rebuild the whole thing a couple of times, but then remembering Einstein's quote "Repeating the same thing and expecting a different output is insanity" i stopped.. That's where you guys come in. Here's the compilation log from which i can't help wondering why the files aren't linking.

Compiler: OpenCV
Building Makefile: "C:\Users\ronnieaka\Desktop\PROJ\openCV\Makefile.win"
Executing  make clean
rm -f ../../../../../opencv/samples/c/facedetect.o  FirstCVproj.exe
g++.exe -c ../../../../../opencv/samples/c/facedetect.cpp -o ../../../../../opencv/samples/c/facedetect.o -I"lib/gcc/mingw32/3.4.2/include"  -I"include/c++/3.4.2/backward"  -I"include/c++/3.4.2/mingw32"  -I"include/c++/3.4.2"  -I"include"  -I"C:/opencv/include"  -I"C:/opencv/include/opencv"  -I"C:/opencv/include/opencv2"  -I"C:/opencv/build/include"  -I"C:/opencv/build/include/opencv"  -I"C:/opencv/build/include/opencv2"    -L"C:\opencv\build\x86\mingw\lib" -llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231
g++.exe: -llibopencv_core231: linker input file unused because linking not done
g++.exe: -llibopencv_imgproc231: linker input file unused because linking not done
g++.exe: -llibopencv_calib3d231: linker input file unused because linking not done
g++.exe: -llibopencv_video231: linker input file unused because linking not done
g++.exe: -llibopencv_features2d231: linker input file unused because linking not done
g++.exe: -llibopencv_ml231: linker input file unused because linking not done
g++.exe: -llibopencv_highgui231: linker input file unused because linking not done
g++.exe: -llibopencv_objdetect231: linker input file unused because linking not done
g++.exe: -llibopencv_contrib231: linker input file unused because linking not done
g++.exe: -llibopencv_legacy231: linker input file unused because linking not done
g++.exe: -llibopencv_flann231: linker input file unused because linking not done
g++.exe ../../../../../opencv/samples/c/facedetect.o  -o "FirstCVproj.exe" -L"lib" -L"C:/opencv/build/x86/mingw/lib" -llibopencv_core231 -llibopencv_imgproc231 -llibopencv_calib3d231 -llibopencv_video231 -llibopencv_features2d231 -llibopencv_ml231 -llibopencv_highgui231 -llibopencv_objdetect231 -llibopencv_contrib231 -llibopencv_legacy231 -llibopencv_flann231  
Execution terminated
Compilation successful

EDIT:

i also tried opencv\samples\c\mushroom.cpp and i got the output window in which the details of the program were printed, about its author etc, but then i got the windows message: "FirstCVproj has stopped working"

Community
  • 1
  • 1
bad_keypoints
  • 1,382
  • 2
  • 23
  • 45

1 Answers1

1

It's possible to see in the command line that you are adding this path as the libraries path:

-L"C:\opencv\build\x86\mingw\lib" 

You need to make sure this is right directory by confirming that all these files can be found in there:

libopencv_core231 libopencv_imgproc231 libopencv_calib3d231 libopencv_video231
libopencv_features2d231 libopencv_ml231 libopencv_highgui231 libopencv_objdetect231 
libopencv_contrib231 libopencv_legacy231 libopencv_flann231

I don't have Dev-C++ installed nor I recommend it. The last official version released dates back to February 22, 2005:

Colin Laplace stated that he was busy with real-life issues and did not have time to continue development of Dev-C++.

I strongly suggest you move to another compiler, if you consider Visual Studio Express (which is free) you can follow this tutorial to configure OpenCV.

EDIT:

The library directory you should be adding it's the one that has .a files, and it may not be same as the one that has the DLLs. Remember, DLLs are used when the application is executed and not when the application is in the building (linkage) process.

EDIT:

Don't include the library files as -llibopencv_core231, do it as -lopencv_core231.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • "libopencv_core231.dll.a" and "libopencv_core231.dll" and others like it are there in the c:\opencv\build\x86\mingw\lib and \bin folders respectively – bad_keypoints Jan 10 '12 at 12:18
  • honestly, i have never worked in MS VC++ and i've found it to be too loaded :) therefore i've been using devcpp for a long time and still using it. – bad_keypoints Jan 10 '12 at 12:19
  • Well, it's entirely up to you. But I don't know a single soul that does this for a living that uses Dev-C++ to develop commercial applications. Another lightweight IDE is [Code::Blocks](http://www.codeblocks.org/). **By the way**, the library directory you should be adding is not the one with the DLLs, it's the one with **.a** files. – karlphillip Jan 10 '12 at 12:24
  • i'm not making any commercial application. i'm trying to build a webcam based eye tracker to move my cursor, just like those guys on youtube. its so awesome. BTW, the library directory i added does have the library files, not the .dll ones. The binaries path i added has the .DLL files – bad_keypoints Jan 10 '12 at 12:31
  • that tutorial you posted about setting up ms vc++ with opencv 2.3, it has this step where we have to goto "Project Properties" (Alt+F7), i don't see Project Properties or anything like it in my MS VC++ 2010 Express, either by pressing the key combination, or going to "Project" – bad_keypoints Jan 10 '12 at 12:39
  • Well, the answer would never get 14 upvotes if it didn't worked, agreed? You need to Google [why this is happening in your IDE](http://stackoverflow.com/questions/231034/properties-page-not-displaying-in-visual-studio-2008). There's a few of similar [reports in Stackoverflow](http://stackoverflow.com/a/4138755/176769). – karlphillip Jan 10 '12 at 12:42
  • [This is also interesting](http://connect.microsoft.com/VisualStudio/feedback/details/650334/vs2010-sp1-caused-vdproj-project-properties-to-no-longer-be-displayed). You can try resetting the user data by running the following command from command prompt (you will lose all your environment settings and customizations): `cmd /c start /wait devenv /setup /resetuserdata /selfreg /resetskippkgs` – karlphillip Jan 10 '12 at 12:49
  • Hey i followed your instructions about configuring opencv with visual c++ express 2010, and i got the error "This application cannot start because opencv_highgui231.dll was not found etc" btw, i'm using vc10's lib and bin directory references wherever you used vc9 in your walkthrough – bad_keypoints Jan 14 '12 at 12:08
  • 1
    alright! i just deleted the semicolon after the binaries path in system enivronment variable Path and it worked! But here's a new thing: Output form Debug ##### 'cv1.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_highgui231.dll', Cannot find or open the PDB file 'cv1.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file ##### what does that mean? PDB file can't be found? Anyways an image i passed as an argument (for which i had to google up how to pass arguments in vc++ hehe) and it showed up Thanks, in all. Your configuration tutorial really worked like magic – bad_keypoints Jan 14 '12 at 12:30
  • Awesome, feel free to accept my answer as the official: you may click on the checkbox near the answer to select as the official and help others with the same problem as yours. – karlphillip Jan 14 '12 at 13:20
  • haha actually the 'answer' would be the one which would get devcpp working with opencv.. I'd have to learn a lot of new things if i work on visual studio. Right now, its kind of a backup plan, just like Python. – bad_keypoints Jan 14 '12 at 13:36
  • In that case, the answer is don't include library files in the form of `-llibopencv_core231` , but instead do `-lopencv_core231`. – karlphillip Jan 14 '12 at 13:57
  • if i do that, it says "cannot find -libopencv_core231; ld returned 1 exit status " – bad_keypoints Jan 16 '12 at 15:30
  • okay, i've decided not to waste my time over the decision of what language or environment to choose. I've got to complete my project, and i need to do it in a timely manner. I may just go with the vc++ setup you helped me with, or python-opencv combination i setup easily. – bad_keypoints Jan 16 '12 at 15:34
  • You didnt follow exactly as I said. Please review my previous comment carefully. – karlphillip Jan 16 '12 at 15:47
  • ohhh.. alright, will try that. didn't observe carefully :P thanks.. will try that as soon as i get back to home – bad_keypoints Jan 17 '12 at 05:00
  • Though i'm not using OpenCV with C/C++, i would recommend the setup given by you. Thanks for your time and sorry for such late acceptance of your answer. I'm doing my project in python, and have so far detected pupils in both eyes, with knowing which is which eye :) Gaze estimation is the real deal that's left now... – bad_keypoints Mar 02 '12 at 07:50
  • @karlphillip am facing the same problem. Please have a look. at the below posts.http://stackoverflow.com/questions/13012274/how-to-setup-opencv2-4-0-with-mingw-in-netbeans,and another post http://stackoverflow.com/questions/13005304/opencv2-4-0-with-mingw-in-windows-get-crashed. Am trying to compile a sample program in opencv using netbeans or devc++ with mingw. Please have a look and pour your suggestions.. – 2vision2 Oct 24 '12 at 09:24