1、参考网址:opencv3.3.0+vs2015+cmake编译opencv x86 - wowo的专栏 - CSDN博客.html(https://blog.csdn.net/ifenghua135792468/article/details/81254908)
2、环境:Win7x64,cn_visual_studio_enterprise_2015_with_update_3_x86_x64_dvd_8923298.iso,cmake-3.14.5-win64-x64.zip,opencv-3.4.6-vc14_vc15.exe
PS:vc14对应VS2015,vc15对应VS2017
3、步骤:
step1、打开cmake,编译opencv源码
3.1、打开cmake:"E:\OpenCV_something\cmake-3.14.5-win64-x64\bin\cmake-gui.exe" 结果如下图:
选择"E:\OpenCV_something\opencv-3.4.6-vc14_vc15\sources",然后 新建文件夹存储cmake编译的结果文件(我这里是新建的"E:\OpenCV_something\opencv-3.4.6-vc14_vc15\build\x86_zz")
3.2.点击左下角的Configure,然后选择对应的vs版本,我的是Visual Studio 14 2015,如下图:
3.3、点击上面图中的 "Finish"按钮,然后会有 一段长时间的 "Configure"操作,输出的信息 在 文章后面的 "txt-01"中
ZC:这一步 忘了截图,但是也 和 参考文章 中的类似,也有 红色的区域
(ZC:上面这张图 是 参考文章中的图)
3.4、再次点击Configure,最后点击Generate,结果如下图,可以关闭cmake了
ZC:这一步 我也没有截图... 可以参看 参考文章 的内容,这一步操作的输出信息 在 文章后面的 "txt-02"中
(ZC:上面这张图 是 参考文章中的图)
step2、用vs编译cmake结果
3.1、打开step1中新建的文件夹"x86_zz"(E:\OpenCV_something\opencv-3.4.6-vc14_vc15\build\x86_zz),找到OpenCV.sln,双击打开(ZC:我是用VS2015打开的)
3.2、先 生成Debug版本的,选择Debug,然后点击 生成-生成解决方案
(ZC:上面这张图 是 参考文章中的图)
3.3、等一段时间后,会显示成功75个,失败0个,然后 解决方案资源管理器-CMake Targets-INSTALL, 右键INSTALL,选择 仅用于项目-仅生成INSTALL
(ZC:上面这张图 是 参考文章中的图)
3.4、然后打开file文件夹,找到install文件夹,里面的x86即opencv3.3.0的x86的Debug版本,剪切这个文件夹放在opencv3.3.0里即可使用
ZC:我的路径是"E:\OpenCV_something\opencv-3.4.6-vc14_vc15\build\x86_zz\install\x86",我把它改名为"E:\OpenCV_something\opencv-3.4.6-vc14_vc15\build\x86_zz\install\x86__debug"
3.5、Release版本重复2-4步,把第2步中的Debug改为Release即可
ZC:同样生成的路径是 "E:\OpenCV_something\opencv-3.4.6-vc14_vc15\build\x86_zz\install\x86",我把它改名为"E:\OpenCV_something\opencv-3.4.6-vc14_vc15\build\x86_zz\install\x86__release"
ZC:这样 "E:\OpenCV_something\opencv-3.4.6-vc14_vc15\build\x86_zz\install"就有两个文件夹:"x86__debug"、"x86__release",里面分别存放着 x86版的 debug和release的bin和lib文件夹,如下图:
ZC:最后 我把 文件夹"E:\OpenCV_something\opencv-3.4.6-vc14_vc15\build\x86_zz" 打包了一下,生成了 "E:\OpenCV_something\opencv-3.4.6-vc14_vc15\build\x86_zz.rar"
4、
txt_01:
The CXX compiler identification is MSVC 19.0.24215.1 The C compiler identification is MSVC 19.0.24215.1 Check for working CXX compiler: E:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe Check for working CXX compiler: E:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Detecting CXX compile features Detecting CXX compile features - done Check for working C compiler: E:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe Check for working C compiler: E:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works Detecting C compiler ABI info Detecting C compiler ABI info - done Detecting C compile features Detecting C compile features - done Performing Test HAVE_CXX11 (check file: cmake/checks/cxx11.cpp) Performing Test HAVE_CXX11 - Success Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7") Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.2") Performing Test HAVE_CPU_SSE3_SUPPORT (check file: cmake/checks/cpu_sse3.cpp) Performing Test HAVE_CPU_SSE3_SUPPORT - Success Performing Test HAVE_CPU_SSSE3_SUPPORT (check file: cmake/checks/cpu_ssse3.cpp) Performing Test HAVE_CPU_SSSE3_SUPPORT - Success Performing Test HAVE_CPU_SSE4_1_SUPPORT (check file: cmake/checks/cpu_sse41.cpp) Performing Test HAVE_CPU_SSE4_1_SUPPORT - Success Performing Test HAVE_CPU_POPCNT_SUPPORT (check file: cmake/checks/cpu_popcnt.cpp) Performing Test HAVE_CPU_POPCNT_SUPPORT - Success Performing Test HAVE_CPU_SSE4_2_SUPPORT (check file: cmake/checks/cpu_sse42.cpp) Performing Test HAVE_CPU_SSE4_2_SUPPORT - Success Performing Test HAVE_CXX_ARCH:AVX (check file: cmake/checks/cpu_fp16.cpp) Performing Test HAVE_CXX_ARCH:AVX - Success Performing Test HAVE_CPU_BASELINE_FLAGS Performing Test HAVE_CPU_BASELINE_FLAGS - Success Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_1 Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_1 - Success Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_2 Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_2 - Success Performing Test HAVE_CPU_DISPATCH_FLAGS_FP16 Performing Test HAVE_CPU_DISPATCH_FLAGS_FP16 - Success Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX - Success Check if the system is big endian Searching 16 bit integer Looking for sys/types.h Looking for sys/types.h - found Looking for stdint.h Looking for stdint.h - found Looking for stddef.h Looking for stddef.h - found Check size of unsigned short Check size of unsigned short - done Using unsigned short Check if the system is big endian - little endian Looking for fseeko Looking for fseeko - not found Check size of off64_t Check size of off64_t - failed libjpeg-turbo: VERSION = 2.0.2, BUILD = opencv-3.4.6-libjpeg-turbo Check size of size_t Check size of size_t - done Check size of unsigned long Check size of unsigned long - done Performing Test HAVE_BUILTIN_CTZL Performing Test HAVE_BUILTIN_CTZL - Failed Looking for include file intrin.h Looking for include file intrin.h - found Looking for assert.h Looking for assert.h - found Looking for fcntl.h Looking for fcntl.h - found Looking for inttypes.h Looking for inttypes.h - found Looking for io.h Looking for io.h - found Looking for limits.h Looking for limits.h - found Looking for malloc.h Looking for malloc.h - found Looking for memory.h Looking for memory.h - found Looking for search.h Looking for search.h - found Looking for string.h Looking for string.h - found Performing Test C_HAS_inline Performing Test C_HAS_inline - Success Check size of signed short Check size of signed short - done Check size of unsigned short Check size of unsigned short - done Check size of signed int Check size of signed int - done Check size of unsigned int Check size of unsigned int - done Check size of signed long Check size of signed long - done Check size of signed long long Check size of signed long long - done Check size of unsigned long long Check size of unsigned long long - done Check size of unsigned char * Check size of unsigned char * - done Check size of ptrdiff_t Check size of ptrdiff_t - done Looking for memmove Looking for memmove - found Looking for setmode Looking for setmode - found Looking for strcasecmp Looking for strcasecmp - not found Looking for strchr Looking for strchr - found Looking for strrchr Looking for strrchr - found Looking for strstr Looking for strstr - found Looking for strtol Looking for strtol - found Looking for strtol Looking for strtol - found Looking for strtoull Looking for strtoull - found Looking for lfind Looking for lfind - found Performing Test HAVE_SNPRINTF Performing Test HAVE_SNPRINTF - Success Check if the system is big endian Searching 16 bit integer Using unsigned short Check if the system is big endian - little endian FFMPEG: Download: opencv_ffmpeg.dll FFMPEG: Download: opencv_ffmpeg_64.dll FFMPEG: Download: ffmpeg_version.cmake Looking for Mfapi.h Looking for Mfapi.h - found Looking for D3D11.h Looking for D3D11.h - found Looking for D3d11_4.h Looking for D3d11_4.h - not found IPPICV: Download: ippicv_2019_win_ia32_20180723_general.zip CMake Warning at cmake/OpenCVDownload.cmake:193 (message): IPPICV: Download failed: 28;"Timeout was reached" For details please refer to the download log file: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/build/x86_zz/CMakeDownloadLog.txt Call Stack (most recent call first): 3rdparty/ippicv/ippicv.cmake:42 (ocv_download) cmake/OpenCVFindIPP.cmake:243 (download_ippicv) cmake/OpenCVFindLibsPerf.cmake:12 (include) CMakeLists.txt:794 (include) Could not find OpenBLAS include. Turning OpenBLAS_FOUND off Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off Looking for sgemm_ Looking for sgemm_ - not found Looking for pthread.h Looking for pthread.h - not found Found Threads: TRUE Could NOT find BLAS (missing: BLAS_LIBRARIES) LAPACK requires BLAS A library with LAPACK API not found. Please specify library location. Found JNI: C:/Program Files (x86)/Java/jdk1.7.0_80/lib/jawt.lib VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file OpenCV Python: during development append to PYTHONPATH: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/build/x86_zz/python_loader Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx2.cpp Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx2.cpp Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp Excluding from source files list: modules/imgproc/src/resize.avx2.cpp Excluding from source files list: modules/imgproc/src/sumpixels.avx512_skx.cpp Excluding from source files list: modules/imgproc/src/undistort.avx2.cpp Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp Excluding from source files list: modules/features2d/src/fast.avx2.cpp General configuration for OpenCV 3.4.6 ===================================== Version control: unknown Platform: Timestamp: 2019-06-16T02:55:24Z Host: Windows 6.1.7601 AMD64 CMake: 3.14.5 CMake generator: Visual Studio 14 2015 CMake build tool: C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe MSVC: 1900 CPU/HW features: Baseline: SSE SSE2 requested: SSE2 Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX requested: SSE4_1 SSE4_2 AVX FP16 SSE4_1 (15 files): + SSE3 SSSE3 SSE4_1 SSE4_2 (2 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 (1 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX AVX (6 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX C/C++: Built as dynamic libs?: YES C++11: YES C++ Compiler: E:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe (ver 19.0.24215.1) C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /arch:SSE /arch:SSE2 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP4 /MD /O2 /Ob2 /DNDEBUG C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /arch:SSE /arch:SSE2 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP4 /MDd /Zi /Ob0 /Od /RTC1 C Compiler: E:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /arch:SSE /arch:SSE2 /MP4 /MD /O2 /Ob2 /DNDEBUG C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /arch:SSE /arch:SSE2 /MP4 /MDd /Zi /Ob0 /Od /RTC1 Linker flags (Release): /machine:X86 /INCREMENTAL:NO Linker flags (Debug): /machine:X86 /debug /INCREMENTAL ccache: NO Precompiled headers: YES Extra dependencies: 3rdparty dependencies: OpenCV modules: To be built: calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo shape stitching superres ts video videoio videostab Disabled: world Disabled by dependency: - Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java js python2 python3 viz Applications: tests perf_tests apps Documentation: NO Non-free algorithms: NO Windows RT support: NO GUI: Win32 UI: YES VTK support: NO Media I/O: ZLib: build (ver 1.2.11) JPEG: build-libjpeg-turbo (ver 2.0.2-62) WEBP: build (ver encoder: 0x020e) PNG: build (ver 1.6.36) TIFF: build (ver 42 - 4.0.10) JPEG 2000: build (ver 1.900.1) OpenEXR: build (ver 1.7.1) HDR: YES SUNRASTER: YES PXM: YES Video I/O: DC1394: NO FFMPEG: YES (prebuilt binaries) avcodec: YES (ver 57.107.100) avformat: YES (ver 57.83.100) avutil: YES (ver 55.78.100) swscale: YES (ver 4.8.100) avresample: YES (ver 3.7.0) GStreamer: NO DirectShow: YES Media Foundation: YES DXVA: NO Parallel framework: Concurrency Trace: YES (with Intel ITT) Other third-party libraries: Lapack: NO Eigen: NO Custom HAL: NO Protobuf: build (3.5.1) OpenCL: YES (NVD3D11) Include path: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/sources/3rdparty/include/opencl/1.2 Link libraries: Dynamic load Python (for build): NO Java: ant: NO JNI: C:/Program Files (x86)/Java/jdk1.7.0_80/include C:/Program Files (x86)/Java/jdk1.7.0_80/include/win32 C:/Program Files (x86)/Java/jdk1.7.0_80/include Java wrappers: NO Java tests: NO Install to: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/build/x86_zz/install ----------------------------------------------------------------- Configuring done
txt-02:
Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7") Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.2") libjpeg-turbo: VERSION = 2.0.2, BUILD = opencv-3.4.6-libjpeg-turbo Looking for Mfapi.h Looking for Mfapi.h - found IPPICV: Download: ippicv_2019_win_ia32_20180723_general.zip found Intel IPP (ICV version): 2019.0.0 [2019.0.0 Gold] at: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/build/x86_zz/3rdparty/ippicv/ippicv_win/icv found Intel IPP Integration Wrappers sources: 2019.0.0 at: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/build/x86_zz/3rdparty/ippicv/ippicv_win/iw Could not find OpenBLAS include. Turning OpenBLAS_FOUND off Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off Could NOT find BLAS (missing: BLAS_LIBRARIES) LAPACK requires BLAS A library with LAPACK API not found. Please specify library location. VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file OpenCV Python: during development append to PYTHONPATH: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/build/x86_zz/python_loader Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx2.cpp Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx2.cpp Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp Excluding from source files list: modules/imgproc/src/resize.avx2.cpp Excluding from source files list: modules/imgproc/src/sumpixels.avx512_skx.cpp Excluding from source files list: modules/imgproc/src/undistort.avx2.cpp Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp Excluding from source files list: modules/features2d/src/fast.avx2.cpp General configuration for OpenCV 3.4.6 ===================================== Version control: unknown Platform: Timestamp: 2019-06-16T02:55:24Z Host: Windows 6.1.7601 AMD64 CMake: 3.14.5 CMake generator: Visual Studio 14 2015 CMake build tool: C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe MSVC: 1900 CPU/HW features: Baseline: SSE SSE2 requested: SSE2 Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX requested: SSE4_1 SSE4_2 AVX FP16 SSE4_1 (15 files): + SSE3 SSSE3 SSE4_1 SSE4_2 (2 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 (1 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX AVX (6 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX C/C++: Built as dynamic libs?: YES C++11: YES C++ Compiler: E:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe (ver 19.0.24215.1) C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /arch:SSE /arch:SSE2 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP4 /MD /O2 /Ob2 /DNDEBUG C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /arch:SSE /arch:SSE2 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP4 /MDd /Zi /Ob0 /Od /RTC1 C Compiler: E:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /arch:SSE /arch:SSE2 /MP4 /MD /O2 /Ob2 /DNDEBUG C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:fast /arch:SSE /arch:SSE2 /MP4 /MDd /Zi /Ob0 /Od /RTC1 Linker flags (Release): /machine:X86 /INCREMENTAL:NO Linker flags (Debug): /machine:X86 /debug /INCREMENTAL ccache: NO Precompiled headers: YES Extra dependencies: 3rdparty dependencies: OpenCV modules: To be built: calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo shape stitching superres ts video videoio videostab Disabled: world Disabled by dependency: - Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java js python2 python3 viz Applications: tests perf_tests apps Documentation: NO Non-free algorithms: NO Windows RT support: NO GUI: Win32 UI: YES VTK support: NO Media I/O: ZLib: build (ver 1.2.11) JPEG: build-libjpeg-turbo (ver 2.0.2-62) WEBP: build (ver encoder: 0x020e) PNG: build (ver 1.6.36) TIFF: build (ver 42 - 4.0.10) JPEG 2000: build (ver 1.900.1) OpenEXR: build (ver 1.7.1) HDR: YES SUNRASTER: YES PXM: YES Video I/O: DC1394: NO FFMPEG: YES (prebuilt binaries) avcodec: YES (ver 57.107.100) avformat: YES (ver 57.83.100) avutil: YES (ver 55.78.100) swscale: YES (ver 4.8.100) avresample: YES (ver 3.7.0) GStreamer: NO DirectShow: YES Media Foundation: YES DXVA: NO Parallel framework: Concurrency Trace: YES (with Intel ITT) Other third-party libraries: Intel IPP: 2019.0.0 Gold [2019.0.0] at: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/build/x86_zz/3rdparty/ippicv/ippicv_win/icv Intel IPP IW: sources (2019.0.0) at: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/build/x86_zz/3rdparty/ippicv/ippicv_win/iw Lapack: NO Eigen: NO Custom HAL: NO Protobuf: build (3.5.1) OpenCL: YES (NVD3D11) Include path: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/sources/3rdparty/include/opencl/1.2 Link libraries: Dynamic load Python (for build): NO Java: ant: NO JNI: C:/Program Files (x86)/Java/jdk1.7.0_80/include C:/Program Files (x86)/Java/jdk1.7.0_80/include/win32 C:/Program Files (x86)/Java/jdk1.7.0_80/include Java wrappers: NO Java tests: NO Install to: E:/OpenCV_something/opencv-3.4.6-vc14_vc15/build/x86_zz/install ----------------------------------------------------------------- Configuring done Generating done
5、
原文地址:https://www.cnblogs.com/cppskill/p/11031456.html