You are on page 1of 6

20/1/2014

How to install OpenCV on Windows 7/8 (64bit) using MinGW (64) and Codeblocks | Zahid Hasan

How to install OpenCV on Windows 7/8 (64bit) using MinGW (64) and Codeblocks
Zahid Hasan February 16, 2013

Guidelines to install OpenCV: 1. Download OpenCV 2.4.3 (http://sourceforge.net/projects/opencvlibrary/) pre-built for windows. However we are not going to use those binaries instead we will make our own. (those pre-built binary sucks most of the time). extract it to C:\OpenCV\ 2. Download codeblocks (www.codeblocks.org/downloads/binaries) without mingw. because the default mingw that comes with codeblocks is 32 bit. Install it to C:\codeblocks\. If you mess up with 64 bit and 32 bit then you are going to have 0xc000007b Error:

(http://zahidhasan.files.wordpress.com/2013/02/0xc000007berror_thumb. jpg) 0xc000007b error due to 32 and 64 bit mix up. 3. Download mingw 64 bit version. you can use online installer from here (http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/) or here (http://sourceforge.net/projects/mingwbuilds/) or offline installer form here (http://tdm-gcc.tdragon.net/) or here (http://www.drangon.org/mingw/). Install it to C:\mingw64\ 4. Download Cmake from here (http://www.cmake.org/cmake/resources/software.html). install it to C:\CMake\ Now you need to set up the path variable. The easiest way to do it using path editor. set the following paths: 1. C:\mingw64\bin 2. C:\CMake\bin Now its time to make our binaries!! 1. Open cmake, set source path to C:\OpenCV\ and binary path
1/6

http://zahidhasan.wordpress.com/2013/02/16/how-to-install-opencv-on-windows-7-64bit-using-mingw-64-and-codeblocks/

20/1/2014

How to install OpenCV on Windows 7/8 (64bit) using MinGW (64) and Codeblocks | Zahid Hasan

to C:\OpenCV_built\. 2. Hit configure button and from dropdown menu select codeblocks MinGW Makefiles and press finish. When it is done press generate button.

(http://zahidhasan.files.wordpress.com/2013/02/cmake4.jpg) Cmake GUI you will find a codeblocks project file (opencv.cbp) in C:\OpenCV_built\ folder. Just double click it and codeblocks will load it. Codeblocks Settings: 1. Go to settings, choose compiler and click Toolchain executable. In the compilers installation directory field choose the bin folder of mingw (C:\MinGW\bin\) 2. Configure the following fields as shown in the image bellow:

(http://zahidhasan.files.wordpress.com/2013/02/codeblock1.jpg) 3. And finally from codeblocks you just need to build it. build target should be set to install so that you can find all the binaries inside the install folder of C:\OpenCV_built\install\. 4. After that set the path C:\OpenCV_built\install\bin\ using path editor. Test run: 1. Create a C++ project Test in codeblocks. right click test project and select build options. 2. from the build options windows select search directories. In the compiler tab chose the followings:
http://zahidhasan.wordpress.com/2013/02/16/how-to-install-opencv-on-windows-7-64bit-using-mingw-64-and-codeblocks/ 2/6

20/1/2014

How to install OpenCV on Windows 7/8 (64bit) using MinGW (64) and Codeblocks | Zahid Hasan

C:\OpenCV_built\install\include C:\OpenCV_built\install\include\opencv C:\OpenCV_built\install\include\opencv2 1. Select Linker tab and add C:\OpenCV_built\install\lib 2. Under Linker Settings tab add required libraries C:\OpenCV_built\install\lib\*.dll.a Test.cpp #include cv.h #include highgui.h using namespace cv; using namespace std; int main() { Mat img; img = imread(pic.jpg); imshow(Original Image, img); waitKey(); }

(http://zahidhasan.files.wordpress.com/2013/02/test.jpg) Thats it! have fun About these ads (http://en.wordpress.com/aboutthese-ads/)

You May Like


1.

http://zahidhasan.wordpress.com/2013/02/16/how-to-install-opencv-on-windows-7-64bit-using-mingw-64-and-codeblocks/

3/6

20/1/2014

How to install OpenCV on Windows 7/8 (64bit) using MinGW (64) and Codeblocks | Zahid Hasan

Bookmark the permalink.

11 thoughts on How to install OpenCV on Windows 7/8 (64bit) using MinGW (64) and Codeblocks
1. ThankYouMan says: May 3, 2013 at 10:05 am The best HowTo Ive found! Thank you very much. It totally worked for me except for a path-issue. You say something like choose the folder C:\MinGW\bin\. But I think its installed to C:\MinGW64\bin\. Maybe you should fix that. Reply 2. Zahid Hasan says: May 4, 2013 at 5:24 am Glad that it helps! You are right, path should be C:\MinGW64\bin\. thanks for the correction. Reply 3. Aditya says: August 11, 2013 at 9:23 am thank you but while building openCV with codeblocks it game me so many errors like invalid function declaration and all.. how to correct it? Reply Zahid Hasan says: August 11, 2013 at 10:00 am Could you be more specific about error? you can post some of the error here Reply 4. roberto says: August 23, 2013 at 7:52 pm could you explain in more detail as I remain in this step And finally from codeblocks you just need to build it. build target should be set to install so that you can find all the binaries inside the install folder of C:\OpenCV_built\install\. After that set the path C:\OpenCV_built\install\bin\ using path editor. Reply Zahid Hasan says: August 24, 2013 at 9:22 am just go to build ->select target -> install in the codeblocks menu and then hit build->build button.
http://zahidhasan.wordpress.com/2013/02/16/how-to-install-opencv-on-windows-7-64bit-using-mingw-64-and-codeblocks/ 4/6

20/1/2014

How to install OpenCV on Windows 7/8 (64bit) using MinGW (64) and Codeblocks | Zahid Hasan

Reply 5. roberto says: August 24, 2013 at 6:20 pm thanks so much form Peru Reply 6. Alesso75 says: October 15, 2013 at 4:19 pm After that set the path C:\OpenCV_built\install\bin\ using path editor. Can u give more details about this step ? I dont know what to do thx Reply 7. yoann says: January 4, 2014 at 1:40 pm after 77 minute and 59 second of building process it failedgiving me the following error/ recipe for tagret install failedI have ni idea what is going onany help would be great Reply 8. peach says: January 9, 2014 at 7:28 pm i dont understand it iii.And finally from codeblocks you just need to build it. build target should be set to install so that you can find all the binaries inside the install folder of C:\OpenCV_built\install\. iv.After that set the path C:\OpenCV_built\install\bin\ using path editor. Test run: i.Create a C++ project Test in codeblocks. right click test project and select build options. ii.from the build options windows select search directories. In the compiler tab chose the followings: C:\OpenCV_built\install\include C:\OpenCV_built\install\include\opencv C:\OpenCV_built\install\include\opencv2 i.Select Linker tab and add C:\OpenCV_built\install\lib ii.Under Linker Settings tab add required libraries C:\OpenCV_built\install\lib\*.dll.a please show picture to me im bad at English thank you so much Reply 9. tomj says: January 12, 2014 at 1:13 pm Where are the include files? Everything seems to have worked but the only content of my include folder is a Cmake fiel. Reply

http://zahidhasan.wordpress.com/2013/02/16/how-to-install-opencv-on-windows-7-64bit-using-mingw-64-and-codeblocks/

5/6

20/1/2014

How to install OpenCV on Windows 7/8 (64bit) using MinGW (64) and Codeblocks | Zahid Hasan

Blog at WordPress.com . The Bushwick Theme. Follow

Follow Zahid Hasan


Powered by WordPress.com

http://zahidhasan.wordpress.com/2013/02/16/how-to-install-opencv-on-windows-7-64bit-using-mingw-64-and-codeblocks/

6/6

You might also like