Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Type a semi colon after the last entry in path and then paste your MinGW path (it should be
C:\MinGW\bin if you chose the default location).
Afterwords open up a command prompt and type path to make sure it worked (you should
see minGW somewhere in the print out, probably near or at the end).
Programs will need to be restarted for this change to take effect.
Step 3: Install Code::Blocks
Code::Blocks is an IDE (integrated development environment). Head to their website and
download the latest version (codeblocks-10.05setup.exe) http://www.codeblocks.org/downloads/binaries
Install it to the default location
When the installer finished click yes to run Code::Blocks
then go to Settings -> Compiler and Debugger
Under the Toolchain Executables select GNU GCC Compiler from the drop down and then
press AutoDetect
verify that Code::Blocks has found MinGW
If you like now might be a good time to test your Code::Blocks and MinGW setup with a
simple Hello World C++ program.
Step 4: Install OpenCV
OpenCV is a library of Computer Vision functions. Head to their website and download the
latest version (2.4.2 for Windows) http://opencv.org/downloads.html
Click on the OpenCV-2.4.2.exe and choose C:\ as the extract directory
When cmake is done we need to open a command prompt in the build directory, so navigate
to C:\opencv\build\x86\mingw then shift right click and choose open command window here
then type mingw32-make. Mingw will now start compiling OpenCV, this will take a bit so
feel free to do something else, when you come back type mingw32-make install and
continue with the rest of the tutorial as is.
Step 5: Add OpenCV to the system path
C:\opencv\build\x86\mingw\bin (use the same process as above)
Note: Add x86 binaries regardless of your system type (32bit or 64bit) because minGW is
32bit.
Verify that both MinGW and OpenCV are in your system path Make sure you restart
Code::Blocks before continuing if you have it open.
Step 6: Configuring Code::Blocks with OpenCV
Make a new Code::Blocks Project:
You can also change the global compiler settings from the menu bar at the top right.
Again Note we are using 32-bit binaries even though the system is 64-bit because the
compiler is 32-bit.
Now run this simple OpenCV Hello World program to test that the install has worked.
1
#include <opencv2/core/core.hpp>
2 #include <opencv2/highgui/highgui.hpp>
3
4 using namespace cv;
5
6 int main()
7 {
Mat image;// new blank image
8
image = cv::imread("test.png", 0);// read the file
9
namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// create a
10window for display.
imshow( "Display window", image );// show our image inside it.
11
waitKey(0);// wait for a keystroke in the window
12
return 0;
13}
14
Download any image you want, rename it test.png or hard code its name and place it in the
top of the project directory.
Note if you run your .exe from outside of code blocks the image needs to be in the same
directory as the .exe.
As I mentioned earlier you can also configure OpenCV using the global compiler and
debugger settings and the steps are the same, this means that every new project is ready to go
with OpenCV. You can also choose file -> save project as template, This allows you to choose
the option new from template and avoid the configuration each time.
Share this:
Twitter3
Facebook49
174 comments
1.
yash
February 24, 2014 at 9:47 am
thanks a lot kevin!
after dozens of websites n hours of waste, your guide came to rescue..
amazing set of guidelines!
thanx again.
Reply
2.
French
February 25, 2014 at 6:03 pm
Many thanks, it works without pain. All other method on the web seems forget
mingw32-make and mingw32-make install steps.
Reply
Salah
1.
3.
Tobias
February 28, 2014 at 10:54 am
Thanks a lot but please add
mingw32-make install
mingw32-make clean
Reply
4.
mahmoud
April 8, 2014 at 1:32 am
thank you <3
Reply
5.
yldzmuhammed
May 12, 2014 at 2:11 pm
Hi.Thanks for this. I have some questions.
I dont understand your;
When cmake is done we need to open a command prompt in the build directory, so
navigate to C:\opencv\build\x86\mingw then shift right click and choose open
command window here then type mingw32-make. Mingw will now start compiling
OpenCV, this will take a bit so feel free to do something else, when you come back
type mingw32-make install and continue with the rest of the tutorial as is. part.
What is that mean?I try open cmd and some command. Like gcc
C:\Opencv\opencv\build\x86\mingw but return error (
http://postimg.org/image/rnqpzazvt/ ).
I tried some combination. And i finish every step.When i compile your simple projects
code, it telling me missing dll file. It said that the libopencv_core243.dll file is
missing.
What should i do?
Reply
Jared
1.
1.
6.
yldzmuhammed
May 12, 2014 at 2:13 pm
Hi.Thanks for this. I have some questions.
kevinhughes27
1.
1.
Salah
December 6, 2014 at 8:22 pm
when i type mingw32-make i find this error :
Help me
2.
Erik
May 21, 2015 at 3:01 pm
7.
arpit
May 13, 2014 at 8:10 pm
i didnt find C:\opencv\build\x86\mingw .
it only shows vc options
i would be glad if u could help
Reply
pallavi
1.
8.
cristianbfristian
May 15, 2014 at 2:37 pm
Ive been having this error and I cant find a way to fix it:
The procedure entry point __gxx_personality_v0 could not be located in the dynamic
link library D:\opencv\build\x86\mingw\bin\libopencv_core249.dll.
Ive looked everywhere for a solution and I need this working soon. I hope you can
help me.
Reply
1.
kh_2011 (@Kh_Fadoua)
July 8, 2014 at 9:05 am
hi,
so pleaze, did you solve this problem ?! coz, actually, im facing it right now,
and i dont really know how to fix it :/
i would be more than grateful of you can answer me asap..
thank you in advance
Reply
9.
cristianbf
May 15, 2014 at 2:40 pm
I get this weird error and I cant find a way to fix it. I looks alike something that other
people had.
The procedure entry point __gxx_personality_v0 could not be located in the dynamic
link library D:\opencv\build\x86\mingw\bin\libopencv_core249.dll.
I dont know how to fix it and I need this working soon. I hope you can help me.
Reply
kevinhughes27
1.
1.
cristianbf
May 15, 2014 at 3:36 pm
Yes. I followed every single step of this tutorial.
10.
kevinhughes27
May 15, 2014 at 3:39 pm
huh dont know what to tell you. Worked for me last time I did it (note that I dont
recommend doing this on windows for several reasons) Try rebuilding them?
Reply
1.
cristianbf
May 15, 2014 at 3:51 pm
Chaithra Bharadwaj
June 6, 2014 at 6:01 am
Works perfectly.. Thanks a lot dude
Reply
14.
CMakeLists.txt
June 21, 2014 at 6:38 pm
CMake Error: The source directory C:/Libs/opencv does not appear to contain
CMakeLists.txt. When clicking configure. Maybe you should address this?
Reply
CMakeLists.txt
1.
1.
15.
Chandrakanth
June 21, 2014 at 10:09 pm
I am getting the following during making mingw32-make.
Krishna Harsha
1.
16.
Pi_Co
July 14, 2014 at 3:04 am
So this is a two part question. The first part being how do you add the picture to the
top of the file directories in the sample script/ I tried just creating a folder for it and
just doing C:\test. The issues is with both approachs I get an unexpected error has
caused name_of_script.exe to stop working. I checked and found that I have
everything linked right so it leads me to the conculsion of it being an error in finding
the test.png photo.
Reply
kevinhughes27
1.
17.
viviwaiwai
18.
Hem
July 29, 2014 at 6:48 pm
hey.bro I followed exactly same steps you have mentioned.My codeblocks is
compiling open cv programs properly but It shows a entry point error missing libstdc+
+-6.dll missing.
And also I cant create project It shows project directory cant be created.
Reply soon Im really worried.
Reply
19.
Harrison Li
August 6, 2014 at 5:15 pm
Thanks a lot for the instruction. I just completed openCV 2.4.9 build using MinGW
64-bit, and tested it. I had some difficulty in the first attempt because of my
environment. Thanks again.
By the way, Im going to install Mint :-)
Best regards.
Reply
kevinhughes27
1.
20.
Harrison Li
1.
1.
anang
September 2, 2014 at 8:57 am
Oh thanks very much sir, :)
2.
AlessioMTX
January 17, 2015 at 5:22 pm
C:\opencv\build\x86\mingw\lib is empty, I dont know why
21.
DVN
September 5, 2014 at 8:15 pm
I agree that developing on the Linux platform makes you code better problem is I
have a desktop and laptop that came with windows 8 preinstalled. this makes it very
difficult to install Linux alongside windows (i have tried and ended up having to reinstall the original image) does anyone have any tips? can it be done cleanly or do I
have to continue using virtual box?
Reply
kevinhughes27
1.
22.
shri
September 10, 2014 at 11:12 am
why here mingw lib file shows format of dll.a where we have .dll lib file.
could it be the reaason for error lib file missing libopencv_core243.dll
Reply
23.
yaman
September 16, 2014 at 1:25 pm
thanks for this tutorial,,,great work,,,helped me a lot,,,
but i want you to note this pointin step-4,
i got stuck here for two days,
using C:\opencv as the source directory gives an errorlocation c:\opencv does not seem to contain Cmakelist.txt file,
Instead of using C:\opencv as the source directory,using C:\opencv\sources did
worked fine.
Thanks again.
Reply
24.
nt
September 23, 2014 at 5:11 pm
kevinhughes27
1.
25.
mfh9498
September 24, 2014 at 1:49 pm
Hello, I got this message when running the Hello World program on Code Blocks:
the procedure entry point __gxx_personality_v0 could not be located in the dynamic
link libstdc++-6.dll > what does this mean? please advise. thank you.
Reply
26.
Dhiyagu
October 3, 2014 at 7:03 am
Hi, Thanks for the post.
I tried it and it throws an error in operations.hpp like
C:\opencv\build\include\opencv2\core\operations.hpp|3869|error: expected primaryexpression before ) token|
Help me out
Reply
27.
Daniel
October 3, 2014 at 1:08 pm
Hi,
Im trying to use Code Blocks and openCV with the tserial.h library.
Everything seems fine with open cv and code blocks, but Im not sure how to add the
tserial.h library to the path.
Ive downloaded it frome here: http://www.tetraedre.com/advanced/serial/ and the
code Im trying to use is here http://www.instructables.com/id/Face-detection-andtracking-with-Arduino-and-OpenC/
The error is: undefined reference to Tserial::Tserial()
If you have any clue of what the problem is, it would be wonderful!
Thanks for your help!
Reply
28.
Fizah Razif
October 10, 2014 at 3:48 pm
hai thank for the tutorial
i already tried. but when i build the coding opencv error came out and im using 64 bit
window. is it ok for me to used 32 bit mingw lib??
Reply
kevinhughes27
1.
29.
Laila Atty
November 18, 2014 at 7:55 pm
Thanks,
but I found a problem to find CMakeLists.txt
I found this Error
CMake Error: The source directory C:/opencv does not appear to contain
CMakeLists.txt.
Specify help for usage, or press the help button on the CMake GUI.
how can I solve this ?
Reply
gabriel
1.
30.
Gabriel
November 22, 2014 at 4:09 pm
after cmake,I found that there is nothing generated in D:/Program
Files/opencv/build/x86/mingw/bin & lib these two directory, even with adding
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
command to my cmakefile.txt.
Is anyone could help me figured out why :( ?
Reply
31. Pingback: Fix Configure Error Zlib Not Installed Mingw Windows XP, Vista, 7, 8
[Solved]
32.
Alexis
February 1, 2015 at 2:57 pm
Thank you very much for this pretty easy tutorial I had unsuccessfully tried to install
OpenCV a few months ago but this time it worked well.
I just want to point out an issue I ran into during compile-time :
something like cannot find -lRunTmChk.
I fixed it by disabling WITH_IPP in CMake, and recompiling.
All the best, from France !
Reply
33.
shweta
February 17, 2015 at 5:14 am
tell me how to install opencv2 for python version 2.7.0 only
Reply
kevinhughes27
1.
34.
Welch
February 19, 2015 at 8:50 pm
I got this error when i try making the cmake generate:
CMake Error: The source directory C:/opencv does not appear to contain
CMakeLists.txt.
Specify help for usage, or press the help button on the CMake GUI.
Reply
Nischal
March 21, 2015 at 4:39 am
hi,
when i type ming32-makei in cmd(at C:\opencv\build\x86\mingw) it shows not
recognized as internal or external command,operable program or batch file.
i created mingw folder at C:\opencv\build\x86 as only vc folders were present. and
then used Cmake.
Reply
Saurabh
1.
37.
Radnap
March 31, 2015 at 2:43 pm
Hi,
Thanks for the article ! While building binaries for MinGW i got an error when
executing mingw-32-make.
http://postimage.org/image/mtgeh7nb7
Reply
Radnap
1.
Ladinde
1.
38.
Italian Job
kevinhughes27
1.
Italian Job
2.
1.
BH
39.
owadesign
April 30, 2015 at 6:33 pm
Hey,
This was exceptionally helpful, but unfortunately, I cannot seem to run the ming32make command successfully. Im getting this error:
C:\MinGW\bin\ar.exe: unable to rename ..\..\lib\libopencv_core_pch_dephelp.a';
reason: File exists
What could I do to resolve this?
Thanks!
Reply
40.
BH
May 29, 2015 at 7:32 pm
Hello, thanks a lot for your infos. builded opencv2.4.9 & mingW. all is ok,
appart from one build error about this:
TBBUTTONINFO was not declared in this scope during make.
just fix it with commctrl.h modification , follow this link. to do the job.
http://code.opencv.org/issues/4087
Many thanks!!
Reply
41.
Ishan a.
June 8, 2015 at 9:13 am
Hi
While running mingw32-make i am getting this error please help.
[ 79%] Generating core+CvException-jdoc.java, core+CvType-jdoc.java, core+Mat-jd
oc.java, core+MatOfByte-jdoc.java, core+MatOfDMatch-jdoc.java,
core+MatOfDouble-
Ishan a.
1.
up vote
2 down
vote
favorite
i am trying to use opencv library with code blocks(8.02).i have installed opencv2.1.
when i include the headers and link the library its all fine.i have gone through
http://opencv.willowgarage.com/wiki/CodeBlocks tutorial as well.but when i
compile the project it reports no error or warning.it just says exit with status 1.
i want to know if anyone who has used opencv with code blocks and can please help
me out of this situation.
thanks!!!
shareimprove this
question
Ashish Yadav
71811122
1
add a comment
1 Answer
active oldest votes
up vote 0 I had this exact same problem a couple of weeks ago and couldn't find an answer
down vote anywhere ! After messing around with it, I found out exactly how to do it.
accepted
2) After your library is compiled you should have two different OpenCV
libraries - a compiled one, and a non-compiled one.
3)In Code Blocks, click on Settings (In the File Menu). Under Settings, select
Compiler and Debugger.
4)Select the Search Directories tab.Select the compiler tab under search
directories. Click Add. Browse to your NON-COMPILED version of the library.
In the non-compiled directory, select the include folder. Under the include
folder, select OpenCV. Click OK
5)In codeblocks, select the linker tab, which is under the Search Directories tab..
Click on add and this time browse to your COMPILED version of the library. In
the compiled directory, select the lib folder and click OK.
6) Go to the linker settings tab in codeblocks. Click Add. Browse to the
COMPILED version of the library. In the compiled directory select lib. In the lib
folder select all the libraries. Make sure to only select only the dynamic library
files (.dylib extention)
7) Codeblocks is setup!
8) Run your project and it should work fine.
Feel free to ask for more help if you are still having problems.
shareimprove this
answer
This question must be duplicate many times, but it just doesn't work and sometimes
it still remains unanswered. Sources of information are mainly these
http://www.laganiere.name/opencvCookbook/chap1s1_2.shtml
http://www.youtube.com/watch?v=dgcXYQijV6c
This is the summation of what I think one should/can do. (And now it works for
me.) Hopefully I mentioned everything from the very beginning, the aim is to write
a very clear tutorial.
Installation of OpenCV for QtCreator
up vote
20 down
vote
favorite
16
C:\Programs\opencv24\opencv_bin
5. Set PATH environment variable, so that there be a link to MinGW
compiler. e.g. C:\Programs\Qt\Qt5.0.1\Tools\MinGW\bin;
6. Start cmake-gui.exe
6.1 source code: set the default dir for OpenCV;
C:\Programs\opencv24\opencv
6.2 binaries: set the opencv_bin dir; C:\Programs\copencv24\opencv_bin
6.3 click configure:
o
6.4 Many red lines will appear To the search field enter one by one:
WITH_QT, WITH_TBB, WITH_IPP, WITH_CUDA,
CMAKE_BUILD_TYPE
o
o
6.5 click configure and keep clicking configure until all red lines are gone,
then click generate and close cmake-gui.exe
7. Go to the terminal (~command prompt), cd to the directory where are the
builds (opencv_bin) and type mingw32-make
8. When the process ends after a long time, type mingw32-make install
9. Add into Path variable the path to the QtCreator/bin
C:\Programs\Qt\Qt5.0.1\Tools\QtCreator\bin
Now I have created a new console app in QtCreator.
//cvHello.pro
QT
+= core
QT
-= gui
TARGET = cvHello
CONFIG
+= console
CONFIG
-= app_bundle
TEMPLATE = app
INCLUDEPATH += C:/Programs/opencv24/opencv_bin2/install/include
LIBS += "C:/Programs/opencv24/opencv_bin2/bin/*.dll"
SOURCES += main.cpp
OTHER_FILES += \
img.JPG
Daniel Katz
3691417
I define LIBS here so that I use a directory opencv_bin2, because I rebuilt
opencv several times. Daniel Katz Apr 8 '13 at 22:43
My project cvImage is available on GitHub and demonstrates how to build a
2 cross-platform application with Qt/OpenCV. Check the .pro file. karlphillip
Apr 9 '13 at 2:28
I had to use "CMAKE_BUILD_TYPE = Release" rather than Debug as given
in here - your first source. inblueswithu Nov 17 '14 at 18:44
Anyways... I could not get this to working!! Not sure.. still pursuing it
inblueswithu Nov 19 '14 at 23:38
In CMake I keep getting this error: "Found unsuitable Qt version "" from
NOTFOUND, this code requires Qt 4.x" Birger Skogeng Pedersen Jan 30 at
10:39
show 1 more comment
1 Answer
active oldest votes
Finally I am starting to be happy. When adjusting this question I had to try all
ways, how to define LIBS. Listing them manually helped, at first I wrote them
somehow wrongly.
This is how it works finally:
up vote 5
down vote
accepted
LIBS += -LC:\\Programs\\opencv24\\opencv_bin2\\bin \
libopencv_core240d \
libopencv_highgui240d \
libopencv_imgproc240d \
libopencv_features2d240d \
libopencv_calib3d240d \
I still don't know what was wrong with the original LIBS +=
"C:/Programs/opencv24/opencv_bin2/bin/*.dll" Daniel Katz Apr 8 '13 at
23:01
you need to add .libs because it contain information about functions inside
DLL, and this information is needed when building the project, so your exe
will run then check those information and then load needed DLL. Wajdy
Essam Apr 9 '13 at 8:20
Wajdy: Do you mean not an extention .lib or .libs, but rather any files within a
directory lib? Probably those in opencv_bin/lib and not opencv_bin/install/lib.
But when I simply change -LC:\\Programs\\opencv24\\opencv_bin2\\bin \ ...
to -LC:\\Programs\\opencv24\\opencv_bin2\\lib \ ... then it doesn't work. Are
you saying that the solution with \\bin \ ... is wrong? Daniel Katz Apr 9 '13
at 18:10
Wajdy: Even if I use the libs in install\lib it cannot find the .dll.a files though I
have a correct path set. Daniel Katz Apr 9 '13 at 18:25
@Wajdy: I've found out that if I use the other bin dir in install\bin, it works
too. But in both ways it doesn't work when I start the program by double click
on the .exe. - cannot find those dlls. Daniel Katz Apr 12 '13 at 18:54
Following this tutorial with OpenCV 2.46 and Qt Creator 2.7.2 was the only
way I was able to make this work. I don't have .NET installed. My .pro looks
like the one in this answer. DanyAlejandro Aug 3 '13 at 21:22
@daniel-katz I'm interested in this topic since I'm building an app with Qt and
OpenCV, and dynamic linking is necessary if one can't pay Qt commercial
fees. Can we get in contact? DanyAlejandro Aug 3 '13 at 21:38
@DanyAlejandro I'm sorry but I myself am not able to link anything
2. Lets start by creating a simple Hello World application on the Windows console, just
to make sure everyting is working properly. Click on Create Project... and choose
Qt Console Application.
We will call our project myHelloWorld; place it in the location of your choice and
click Next.
This one does nothing except launching the concole. Click on the green arrow and you
will see it.
3. Lets now write a true Hello World application. Simply copy and paste the
And click again on the green arrow to run the new code.
If you obtain the result above, then everything is working well. Note that Qt
automatically created a directory called myHelloWorld-build-desktop where it puts
all the compiled and executable files. This way, the source code and the binary files
does not get mixed together. This is very useful, if you use a version control software
such as Subversion in which you submit only the source directory.
12. Let's now proceed to OpenCV installation. To download the OpenCV library, just go
Once this is done, you now have all OpenCV source files in the specified directory.
13. The next step is to compile the library for the compiler you want to use; here it will be
the basic mingw/g++ compiler that Qt installed by default. Just before we do this, let's
include the folder that contains the make command in our Path environment variable.
Indeed, compiling the library will be done using this make utility command that Qt
installed together with the compilers themselves. They are located in
C:\QtSDK\mingw\bin. Goto to your Control Panel (from the Start menu) and to the
System menu.
In the Advanced system settings menu, you select the Advanced tab.
In the User variables box, look for the PATH variable. If it is there, click on
Edit..., if not click on New... to create it. This variable contains all the folder
Windows will look in when you type a command. By setting it in the user variables,
this definition is available to you only. If you want it to be valid for all users of your
system then define it in the System variables box.
14. To build the library from the source files, OpenCV uses CMake, a cross-platform and
open source tool designed to build library packages. We need to install CMake. Go to
cmake.org and download the Windows Win32 Installer.
15. Once CMake installed, you can start the gui-based application (cmake-gui)
In CMake, specify the directory containing the source code and the one that will
contain the builds.
You then specify the compilers that will generate the project. In our case, they are the
compilers of MinGW installed by default by Qt.
Select the build type, here Release. If you wish, at the end, you can repeat the same
process with the Debug mode.
16. Now that you have completed the installation, you are ready to compile the OpenCV
library. Start the Windows cmd console and go to the directory where you installed
your builds. Type mingw32-make
This last step will install the library and the include files in the install directory.
Note that for clarity, you can rename this directory as release since you ask CMake
to build a Release install
environment variable. First, you need to tell your system where to find the
OpenCV dlls. From our installation process, they are in C:\OpenCV2.3.1\install\bin.
Path
The Qt dlls are also required; you should find them at C:\QtSDK\QtCreator\bin
18. Our last step is to build a simple OpenCV project to make sure everything is working
properly. Start Qt and create a new Qt Console Application project called here
myFirstOpenCVProject. Goto to the projects menu and select the Release build
configuration.
The project file must specify the OpenCV headers and libraries locations:
QT
+= core
QT
-= gui
TARGET = myFirstOpenCVProject
CONFIG
+= console
CONFIG
-= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\\OpenCV-2.3.1\\install\\include
LIBS += -LC:\\OpenCV-2.3.1\\install\\lib \
-lopencv_core231.dll \
-lopencv_highgui231.dll \
-lopencv_imgproc231.dll \
-lopencv_features2d231.dll \
-lopencv_calib3d231.dll
You basically just have to add the last two definitions to the existing project:
Make sure you have an image called img.jpg in your myFirstOpenCVProjectbuild-desktop directory that is the default directory when you run your project from
Qt.
Wow! But this is just the beginning, you can do much more with OpenCV... Good
luck!