如何为iOS构建OpenCV 2.4.9? [英] How to build OpenCV 2.4.9 for iOS?
问题描述
我按照这些说明,属于openCV文件,但他们真的过时:提到的iOS4或iOS5,XCode 4.2安装在/ Developer等。
I am following these instructions which belong to the openCV doc, but they are really outdated: iOS4 or iOS5 is mentioned, XCode 4.2 installed in /Developer, etc..
它不构建,我有各种错误:
It doesn't build, and I have various errors:
所有初始测试失败: - 执行测试HAVE_CXX_W - 失败
此外:
All of the initial tests fail: -- Performing Test HAVE_CXX_W - Failed
Also:
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Looking for sys/types.h
-- Looking for sys/types.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - not found
-- Looking for stddef.h
-- Looking for stddef.h - not found
配置看起来是正确的:
-- General configuration for OpenCV 2.4.9 =====================================
-- Version control: 2.4.5-1168-g0a42a3e
--
-- Platform:
-- Host: Darwin 12.3.0 i386
-- Target: iOS
-- CMake: 2.8.10
-- CMake generator: Xcode
-- CMake build tool: /opt/local/bin/cmakexbuild
-- Xcode: 4.6.2
[...]
-- Media I/O:
-- ZLib: build (ver 1.2.7)
-- JPEG: build (ver 90)
-- WEBP: NO
-- PNG: build (ver 1.5.12)
-- TIFF: NO
-- JPEG 2000: NO
-- OpenEXR: NO
--
-- Video I/O:
-- AVFoundation: YES
-- QuickTime: NO
-- QTKit: YES
-- V4L/V4L2: NO/NO
但后来,我有第一个链接错误:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool:无法打开文件:/ Users / ant / xcode / opencv / ios / build / iPhoneOS -armv7 / 3rdparty / libjpeg / OpenCV.build / Release-iphoneos / libjpeg.build / Objects-normal / armv7 / jmemansi.o
But later, I have this first linking error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Users/ant/xcode/opencv/ios/build/iPhoneOS-armv7/3rdparty/libjpeg/OpenCV.build/Release-iphoneos/libjpeg.build/Objects-normal/armv7/jmemansi.o
推荐答案
根据3rdParty / libjpeg / CMakeLists.txt:12,jmemansi .c从构建中排除:
As per 3rdParty/libjpeg/CMakeLists.txt:12, jmemansi.c is excluded from build :
if(ANDROID OR IOS)
ocv_list_filterout(lib_srcs jmemansi.c)
else()
ocv_list_filterout(lib_srcs jmemnobs.c)
endif()
但是,在world模块构建中,相应的目标文件不会从链接器输入中排除。这可以通过从链接器输入中过滤出jmemansi.o来修复:
However, in world module build, the corresponding object file is not excluded from linker input. This can be fixed by filtering out jmemansi.o from linker input :
modules / world / CMakeLists.txt:84
modules/world/CMakeLists.txt:84
macro(ios_include_3party_libs)
foreach(l ${ARGN})
add_dependencies(${the_module} ${l})
string(REGEX REPLACE "<MODULE_NAME>" "${l}" objpath1 "${CMAKE_BINARY_DIR}/3rdparty/${l}/${objpath0}")
file(GLOB sources ${CMAKE_SOURCE_DIR}/3rdparty/${l}/*.c)
foreach(srcname ${sources})
if(IS_ABSOLUTE "${srcname}")
file(RELATIVE_PATH srcname "${CMAKE_SOURCE_DIR}/3rdparty/${l}" "${srcname}")
endif()
string(REPLACE ".." "__" srcname "${srcname}")
get_filename_component(srcname_we ${srcname} NAME_WE)
string(REGEX REPLACE <SRC_NAME_WE> "${srcname_we}" objpath2 "${objpath1}")
string(REGEX REPLACE <RELATIVE_SRC_NAME> "${srcname}" objpath3 "${objpath2}")
list(APPEND objlist "\"${objpath3}\"")
endforeach() # (srcname ${sources})
endforeach()
ocv_list_filterout(objlist jmemansi) # <<= dirty fix
endmacro()
这篇关于如何为iOS构建OpenCV 2.4.9?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!