Ask Your Question
10

Guide for installing and compiling OpenCV with CMake and Visual Studio 2013

asked 2014-05-06 04:37:07 -0600

Y Simson gravatar image

updated 2014-05-07 17:32:17 -0600

After spending many hour doing trial and error in order to compile OpenCV with Eigen, TBB I made a simple text installation guide.

If you want to add to this or make corrections feel free.

A) Get OpenCV source code Open Folder called opencv Fork from github: https://github.com/Itseez/opencv , into subfolder sources Open folder next to sources called build

Now you have:
    opencv--build
          '-sources

Note: You can download the source directly as a zip file or clone it using git, tortoiseGit, svn or tortoise SVN. I cloned the file using TortoiseGit and renamed the file opencv to sources

How to clone using git at command line?
Open a command line window
cd to d:
mkdir opencv
type: git clone https://github.com/Itseez/opencv.git

You should get the following message:
Cloning into 'opencv'...

Soon you will have OpenCV source code in subfolder named 'd:\opencv\opencv'
Move the contents of 'd:\opencv\opencv' to 'd:\opencv\sources'

Here is a really good tutorial on using Git to clone source code from Github

B) Download TBB Under build open subfolder common and put Itel's tbb into it

C) Download Eigen and also put it under build/common

Make sure you put the entire "Eigen" directory under common. It should include at least "eigen" and "unsupported"

D) Download CMake

E) Define as system variable OPENCV64_DIR = d:/opencv/build/

How to check if you entered the path correctly? AFTER entering path and ONLY AFTER entering and applying all your changes open a DOS cmd window. 
Type %OPENCV64_DIR% at the command line
If you get the following message:

'd:/opencv/build/' is not recognized as an internal or external command, operable program or batch file.

You have entered the path correctly and now it is a system variable

F) Add to Path, the following: 1) C:\Program Files (x86)\CMake 2.8\bin; 2) %OPENCV64_DIR%bin\Debug\; 3) %OPENCV64_DIR%bin\Release\; 4) %OPENCV64_DIR%common\tbb\bin\intel64\vc12\;

Note: Use V12 for Visual studio 2013. If you are using an earlier version for example Visual Studio 2010 instead of vc12 use vc10.
How to know which number is the right one for you? Take a look at project configuration properties->General->Platform Toolset

How to check if you entered the Paths correctly?
Type Path at the command line. You should see the Paths you just added in the list

G) Open Cmake gui

Enter the following at:
Where is the Source code: d:/opencv/sources
Where to build the binaries: d:/opencv/build

H) Configure Cmake

Click on configure and you will be asked to specify the compiler. You can use Native compilers but expect no guarantees of success. Rather specify the compiler. The recommend option for x64 architecture regardless of whether you have Intel or AMD microprocessor is to use AMD64. Yes this is confusing but AMD64 is only called that since AMD made a x64 processor first.

-Define native compiler as: c:\Program Files (x86)\Microsoft Visual ...
(more)
edit retag flag offensive close merge delete

Comments

1

You should add this guide as a pull request to the tutorial section. Nice work!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-06 04:41:03 -0600 )edit
1

It is still not perfect. I am having trouble compiling Python. Once I am sure it is perfect I will do that. thanks for the feedback!

Y Simson gravatar imageY Simson ( 2014-05-07 04:34:19 -0600 )edit

Yeah try to be sure that it actuall works before submitting. Would be quite annoying if it didnt work.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-07 04:39:15 -0600 )edit

It works perfectly except for the opencv_python project.

I have a problem at compile time with this project. I have python27.lib but not python27d.lib. Which means It should at least compile for Release Configuration. Which it doesn't.

I avoided the problem by manually deleting the opencv_python project. I still have yet to find a good solution.

Any ideas?

Y Simson gravatar imageY Simson ( 2014-05-07 07:05:14 -0600 )edit
1

Well I am not using the python interface so basically I am never building it just to avoid problems with stuff I don't need. Can't help you out there. Sorry.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-07 08:41:30 -0600 )edit
1

Nice updates!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-08 02:00:22 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-05-31 19:09:18 -0600

SABER gravatar image

But in win 8.1 , cmake dont work

edit flag offensive delete link more

Comments

I am using Window 7 so I haven't tried in Windows 8.

Have you tried all of the with the latest Cmake-Gui? I haven't heard about anyone having problems before.

Y Simson gravatar imageY Simson ( 2014-06-02 06:17:10 -0600 )edit

Question Tools

Stats

Asked: 2014-05-06 04:37:07 -0600

Seen: 44,489 times

Last updated: May 31 '14