opencv 编译 -- 菜鸟学习记录,高手请绕道。

     初次接触一种东西,总是会遇到很多意想不到的问题,尤其是技术性的问题,细节多,规则也多,一步一个陷阱,能够尽快的理出思路,找到头绪,则是快速解决问题的关键。

     最近开始基础openCV,希望了解一点里面的算法,用于自己的产品中,然而,初次接触,再加上,是在之前很少接触的windows平台上,真是吃尽苦头。

     最近版本的openCV2.0提供的动态链接库,看是活生生的存在于bin目录下,编译链接,运行程序时却总是提示找不到,而VS的提示也让人摸不着头脑,明明是某函数不能加载,却提示成另外一个函数找不到。一气之下,打算重新编译一下opencv。

    由于也是初次使用微软的编译环境,一切都得学习,于是百度+google,然而搜到的内容大多是将如何配置一个使用opencv进行应用开发的配置,很少有文章涉及opencv的编译。想来技术这种事情本来就是,对于过来人,举重若轻,对于菜鸟,真是泰山压顶!

   经历了很长时间的闭门羹后,终于还是在opencv自带的doc目录下,发现了编译的提示:

              http://opencv.willowgarage.com/wiki/InstallGuide

windows和linux的步骤混合在一起。看起来也不轻松, 下面是我整理后的步骤(一共11步):

    

build the openCV step by step:

1.      download the openCV and install it, assuming: D:/Program Files/OpenCV2.0

2.      download the cmake and install it.

3.      download VS studio and install it

4.      create a directory under the opencv directory: D:/Program Files/OpenCV2.0/release

5.      >cd D:/Program Files/OpenCV2.0

6.      execute D:/Program Files/OpenCV2.0 ../

7.      the cmake will generate the project files for VS under D:/Program Files/OpenCV2.0/release

get the following output:

D:/Program Files/OpenCV2.0/release>cmake -D:CMAKE_BUILD_TYPE=RELEASE ../

-- Building for: Visual Studio 8 2005

-- Check for working C compiler: D:/Program Files/Microsoft Visual Studio/VC98/B

in/CL.EXE

-- Check for working C compiler: D:/Program Files/Microsoft Visual Studio/VC98/B

in/CL.EXE -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check for working CXX compiler: D:/Program Files/Microsoft Visual Studio/VC98

/Bin/CL.EXE

-- Check for working CXX compiler: D:/Program Files/Microsoft Visual Studio/VC98

/Bin/CL.EXE -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Could NOT find PythonInterp  (missing:  PYTHON_EXECUTABLE)

-- Could NOT find PythonLibs  (missing:  PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)

-- IPP detected:

-- Parsing 'cvconfig.h.cmake'

CMake Warning (dev) at CMakeLists.txt:689 (if):

  given arguments:

 

    ""

 

  An argument named "" appears in a conditional statement.  Policy CMP0012 is

  not set: if() recognizes numbers and boolean constants.  Run "cmake

  --help-policy CMP0012" for policy details.  Use the cmake_policy command to

  set the policy and suppress this warning.

This warning is for project developers.  Use -Wno-dev to suppress it.

 

CreateProcessError: The system cannot find the file specified.

 

for command: mkdir -p "D:/Program Files/OpenCV2.0/release/unix-install/"

CreateProcessError: The system cannot find the file specified.

 

for command: mkdir -p "D:/Program Files/OpenCV2.0/release/win-install/"

--

-- General configuration for opencv 2.0.0 =====================================

--

--     Compiler:

--     C++ flags (Release):        /DWIN32 /D_WINDOWS /W4 /Zm1000 /EHsc /GR  /D

_CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS

  /Wp64 /openmp /Gy  /MD /O2 /Ob2 /D NDEBUG  /Zi

--     C++ flags (Debug):          /DWIN32 /D_WINDOWS /W4 /Zm1000 /EHsc /GR  /D

_CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS

  /Wp64 /openmp /Gy  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1

--     Linker flags (Release):     /STACK:10000000 /machine:I386    /INCREMENTAL

:NO  /debug

--     Linker flags (Debug):       /STACK:10000000 /machine:I386    /debug /INCR

EMENTAL:YES

--

--   Interfaces:

--     Old Python:                0

--     Python:                    ON

--     Use IPP:                   NO

--     Build Documentation         0

--

--     Install path:              D:/Program Files/OpenCV2.0/release

--

--     cvconfig.h is in:          D:/Program Files/OpenCV2.0/release

-- -----------------------------------------------------------------

--

-- Configuring done

-- Generating done

-- Build files have been written to: D:/Program Files/OpenCV2.0/release

 

8.      get into directory release and open the VS, compile all

9.      after complete the compile, the There are several directories will be created under the D:/Program Files/OpenCV2.0/release:

     D:/Program Files/OpenCV2.0/release/lib/debug – the leading description of the opencv dlls

     D:/Program Files/OpenCV2.0/release/bin/debug – the dll directory, adding it to the PATH environment variable.

    

10.   start to use the openCV for build one’s own application, create a VS project,

“配置属性”---“连接器”---“常规”的“附件库目录”:

D:/Program Files/OpenCV2.0/release/lib/debug

Add following libs to “配置属性”---“连接器”---“输入”的“附加依赖项”

  "cv200d.lib "

"cvaux200d.lib"

"cvhaartraining.lib"

"cxcore200d.lib"

"cxts200d.lib"

"highgui200d.lib"

"ml200d.lib"

"opencv_ffmpeg200d.lib"

"libml200.dll.a"

11.   environment is ok now, you get the ball.

你可能感兴趣的:(opencv 编译 -- 菜鸟学习记录,高手请绕道。)