2016年10月20日 星期四

Steps for Building OpenCV Static Libraries in Win7

Versions:
  • OpenCV 3.1.0-dev
  • CMake 3.7.0-rc2-win32-x86
  • TDC-GCC 5.1.0-tdm-1
  • Python 2.7

First, in CMake...
 Step 01: Uncheck 'BUILD_SHARED_LIBS' 
 Step 02: Uncheck 'BUILD_opencv_python2' 
 Step 03: Set the value of 'CMAKE_EXE_LINKER_FLAGS' to '-static'.

 then, do 'Configure' several times until all red background disappeared.
 and then, 'Generate' the make file for compiler.

Second, in command shell (Microsoft Powershell could be better)...
 Step 01: change your working directory to 'C:\OpenCV\build\'
 Step 02: run 'mingw32-make'
 Step 03: run 'mingw32-make install'

Third, in Code Blocks...
 Step 01: add all *.a file in folder 'C:\OpenCV\build\install\x86\mingw\staticlib' into 'Link Libraries:'.
 Step 02: add next 5 lines into 'Other Linker options:'.

      -static
      -static-libgcc
      -static-libstdc++
      -Wl,--start-group
      -mwindows'

 Step 03: set 'Search directories of Compiler' to 'C:\OpenCV\build\install\include'.
 Step 04: set 'Search directories of Linker' to 'C:\OpenCV\build\install\x86\mingw\staticlib'.

 then, build and run your code.

沒有留言:

張貼留言

網誌存檔