1
votes

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"

1

1 Answers

1
votes

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.