使用 Xcode 4.6 在 Mac OS X Lion (10.8.2) 上安装 OpenCV
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15388715/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install OpenCV on Mac OS X Lion (10.8.2) with Xcode 4.6
提问by Mir23
My steps for installing OpenCV on my Machine (MBP, 15", 2.5 GHz i7, 16GB RAM, AMD Radeon HD 6770M, 128GB SSD)
我在我的机器上安装 OpenCV 的步骤(MBP,15",2.5 GHz i7,16GB RAM,AMD Radeon HD 6770M,128GB SSD)
- i install git command line tools
- latest macports version installed
- cmake installed with
$ sudo port install cmake
- clone repo of opencv
$ git clone git://code.opencv.org/opencv.git
after repo is on my machine, I changed to this directory and make a new directory
$ cd opencv $ mkdir build $ cd build
then I run
$ cmake -G “Unix Makefiles” ../
after that I get
`-- checking for module 'libdc1394-2' -- package 'libdc1394-2' not found -- checking for module 'libdc1394' -- package 'libdc1394' not found -- checking for module 'libv4l1' -- package 'libv4l1' not found -- Looking for linux/videodev.h -- Looking for linux/videodev.h - not found -- Looking for linux/videodev2.h -- Looking for linux/videodev2.h - not found -- Looking for sys/videoio.h -- Looking for sys/videoio.h - not found -- checking for module 'libavcodec' -- package 'libavcodec' not found -- checking for module 'libavformat' -- package 'libavformat' not found -- checking for module 'libavutil' -- package 'libavutil' not found -- checking for module 'libswscale' -- package 'libswscale' not found -- Looking for libavformat/avformat.h -- Looking for libavformat/avformat.h - not found -- Looking for ffmpeg/avformat.h -- Looking for ffmpeg/avformat.h - not found -- Could NOT find PythonLibs: Found unsuitable version "2.7.2", but required is exact version "2.7.3" (found /usr/lib/libpython2.7.dylib) Traceback (most recent call last): File "", line 1, in ImportError: No module named numpy.distutils
-- Found apache ant 1.8.2: /usr/bin/ant
-- General configuration for OpenCV 2.4.9 =====================================
-- Version control: 2.4.4-642-g061dd7e
-- Platform: -- Host: Darwin 12.2.0 i386 -- CMake: 2.8.10 -- CMake generator: Unix Makefiles -- CMake build tool: /usr/bin/make
-- Configuration: Release
-- C/C++: -- Built as dynamic libs?: YES -- C++ Compiler: /usr/bin/c++ (ver 4.2.0) -- C++ flags (Release): -W -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -DNDEBUG -- C++ flags (Debug): -W -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -g -O0 -DDEBUG -D_DEBUG -ggdb3 -- C Compiler: /usr/bin/cc -- C flags (Release): -W -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -DNDEBUG -- C flags (Debug): -W -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -g -O0 -DDEBUG -D_DEBUG -ggdb3 -- Linker flags (Release):
-- Linker flags (Debug):-- Precompiled headers: NO
-- OpenCV modules: -- To be built: core imgproc flann highgui features2d calib3d ml video objdetect contrib nonfree photo legacy gpu java softcascade stitching ts videostab -- Disabled: world -- Disabled by dependency: -
-- Unavailable: androidcamera ocl python
-- GUI: -- QT 4.x: NO -- Cocoa: YES
-- OpenGL support: NO
-- Media I/O: -- ZLib: build (ver 1.2.7) -- JPEG: build (ver 90) -- WEBP: build (ver 0.2.1) -- PNG: build (ver 1.5.12) -- TIFF: build (ver 42 - 4.0.2) -- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: build (ver 1.7.1)
-- Video I/O: -- DC1394 1.x: NO -- DC1394 2.x: NO -- FFMPEG: YES -- codec: YES (ver Unknown) -- format: YES (ver Unknown) -- util: YES (ver Unknown) -- swscale: YES (ver Unknown) -- gentoo-style: YES -- OpenNI: NO -- OpenNI PrimeSensor Modules: NO -- PvAPI: NO -- GigEVisionSDK: NO -- QuickTime: NO -- QTKit: YES
-- V4L/V4L2: NO/NO
-- Other third-party libraries: -- Use IPP: NO -- Use Eigen: NO -- Use TBB: NO -- Use OpenMP: NO -- Use GCD YES -- Use Concurrency NO -- Use C=: NO -- Use Cuda: NO
-- Use OpenCL: NO
-- Python:
-- Interpreter: /opt/local/bin/python2 (ver 2.7.3)
-- Java: -- ant: /usr/bin/ant (ver 1.8.2) -- JNI: /System/Library/Frameworks/JavaVM.framework/Headers /System/Library/Frameworks/JavaVM.framework/Headers /System/Library/Frameworks/JavaVM.framework/Headers
-- Java tests: YES
-- Documentation: -- Build Documentation: NO -- Sphinx: NO
-- PdfLaTeX compiler: NO
-- Tests and samples: -- Tests: YES -- Performance tests: YES
-- C/C++ Examples: NO
-- Install path: /usr/local
-- cvconfig.h is in: /Users/miralemcebic/Desktop/ocv/opencv/build
-- -----------------------------------------------------------------
-- Configuring done -- Generating done -- Build files have been written to: /Users/miralemcebic/Desktop/ocv/opencv/build`
than I run
$ cmake -G “Unix Makefiles” ../
Now here comes the errors and of the end by 30% I get this
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [lib/libopencv_highgui.2.4.9.dylib] Error 1 make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2 make: *** [all] Error 2
- 我安装了 git 命令行工具
- 安装了最新的 macports 版本
- cmake 安装
$ sudo port install cmake
- 克隆opencv的repo
$ git clone git://code.opencv.org/opencv.git
repo 在我的机器上后,我切换到这个目录并创建一个新目录
$ cd opencv $ mkdir build $ cd build
然后我跑
$ cmake -G “Unix Makefiles” ../
之后我得到
`-- 检查模块“libdc1394-2”——未找到包“libdc1394-2”——检查模块“libdc1394”——未找到包“libdc1394”——检查模块“libv4l1”——包“libv4l1” ' 未找到 -- 寻找 linux/videodev.h -- 寻找 linux/videodev.h - 未找到 -- 寻找 linux/videodev2.h -- 寻找 linux/videodev2.h - 未找到 -- 寻找 sys /videoio.h -- 正在寻找 sys/videoio.h -- 未找到 -- 检查模块“libavcodec” -- 未找到包“libavcodec” -- 检查模块“libavformat” -- 未找到包“libavformat” --检查模块“libavutil”——未找到包“libavutil”——检查模块“libswscale”——包“libswscale”未找到 -- 寻找 libavformat/avformat.h -- 寻找 libavformat/avformat.h -- 未找到 -- 寻找 ffmpeg/avformat.h -- 寻找 ffmpeg/avformat.h -- 未找到 -- 找不到 PythonLibs :发现不合适的版本“2.7.2”,但需要精确的版本“2.7.3”(找到/usr/lib/libpython2.7.dylib)回溯(最近一次调用):文件“”,第1行,导入错误: 没有名为 numpy.distutils 的模块
-- 找到 apache ant 1.8.2: /usr/bin/ant
-- OpenCV 2.4.9 的一般配置 ======================================
-- 版本控制:2.4.4-642-g061dd7e
-- 平台: -- 主机:Darwin 12.2.0 i386 -- CMake:2.8.10 -- CMake 生成器:Unix Makefiles -- CMake 构建工具:/usr/bin/make
-- 配置:发布
-- C/C++: -- 构建为动态库?: 是 -- C++ 编译器:/usr/bin/c++ (ver 4.2.0) -- C++ 标志(发布):-W -Werror=return-type -Werror =non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign -promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -DNDEBUG -- C++ 标志(调试):-W -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit -self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -g -O0 -DDEBUG -D_DEBUG -ggdb3 -- C 编译器:/usr/bin/cc -- C 标志(发布):-W -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit -self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -O3 -DNDEBUG -DNDEBUG -- C 标志(调试):-W -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit -self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -g -O0 -DDEBUG -D_DEBUG -ggdb3 -- 链接器标志(发布):
-- 链接器标志(调试):-- 预编译头文件:NO
-- OpenCV 模块: -- 待构建:核心 imgproc flann highgui features2d calib3d ml video objdetect contrib nonfree photo legacy gpu java softcascade 拼接 ts videostab -- 禁用:world -- 依赖项禁用:-
-- 不可用:androidcamera ocl python
-- GUI: -- QT 4.x: 否 -- Cocoa: 是
-- OpenGL 支持:否
-- 媒体 I/O: -- ZLib: build (ver 1.2.7) -- JPEG: build (ver 90) -- WEBP: build (ver 0.2.1) -- PNG: build (ver 1.5.12) - - TIFF: build (ver 42 - 4.0.2) -- JPEG 2000: build (ver 1.900.1)
-- OpenEXR:构建(1.7.1 版)
-- 视频 I/O: -- DC1394 1.x: NO -- DC1394 2.x: NO -- FFMPEG: YES -- codec: YES (ver Unknown) -- format: YES (ver Unknown) -- util: YES (ver Unknown) -- swscale: YES (ver Unknown) -- gentoo-style: YES -- OpenNI: NO -- OpenNI PrimeSensor Modules: NO -- PvAPI: NO -- GigEVisionSDK: NO -- QuickTime: NO -- QTKit:是的
-- V4L/V4L2:否/否
-- 其他第三方库: -- 使用 IPP: NO -- 使用 Eigen: NO -- 使用 TBB: NO -- 使用 OpenMP: NO -- 使用 GCD YES -- 使用并发 NO -- 使用 C=: NO - - 使用 Cuda:否
-- 使用 OpenCL:否
- Python:
-- 解释器:/opt/local/bin/python2 (ver 2.7.3)
-- Java: -- ant: /usr/bin/ant (ver 1.8.2) -- JNI: /System/Library/Frameworks/JavaVM.framework/Headers /System/Library/Frameworks/JavaVM.framework/Headers /System /Library/Frameworks/JavaVM.framework/Headers
-- Java 测试:是
-- 文档:-- 构建文档:否 -- Sphinx:否
-- PdfLaTeX 编译器:否
-- 测试和样品: -- 测试:是 -- 性能测试:是
-- C/C++ 示例:否
-- 安装路径:/usr/local
-- cvconfig.h 在:/Users/miralemcebic/Desktop/ocv/opencv/build
-------------------------------------------------- -----------------
-- 配置完成 -- 生成完成 -- 构建文件已写入:/Users/miralemcebic/Desktop/ocv/opencv/build`
比我跑
$ cmake -G “Unix Makefiles” ../
现在出现了错误,最后 30% 我明白了
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [lib/libopencv_highgui.2.4.9.dylib] Error 1 make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2 make: *** [all] Error 2
What is here the Problem? I also have Python 2.7 and Python >3
这里的问题是什么?我也有 Python 2.7 和 Python >3
Can anybody help me by this issue?
有人可以帮我解决这个问题吗?