cmake版本:2.8.12
XCode版本:5.0.2
IOS版本生成方法参照:http://docs.opencv.org/trunk/doc/tutorials/introduction/ios_install/ios_install.html#ios-installation
首先是link错误:
/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
解决方案:
modules/world/CMakeLists.txt:84
1 macro(ios_include_3party_libs) 2 foreach(l ${ARGN}) 3 add_dependencies(${the_module} ${l}) 4 string(REGEX REPLACE "<MODULE_NAME>" "${l}" objpath1 "${CMAKE_BINARY_DIR}/3rdparty/${l}/${objpath0}") 5 file(GLOB sources ${CMAKE_SOURCE_DIR}/3rdparty/${l}/*.c) 6 foreach(srcname ${sources}) 7 if(IS_ABSOLUTE "${srcname}") 8 file(RELATIVE_PATH srcname "${CMAKE_SOURCE_DIR}/3rdparty/${l}" "${srcname}") 9 endif() 10 11 string(REPLACE ".." "__" srcname "${srcname}") 12 get_filename_component(srcname_we ${srcname} NAME_WE) 13 string(REGEX REPLACE <SRC_NAME_WE> "${srcname_we}" objpath2 "${objpath1}") 14 string(REGEX REPLACE <RELATIVE_SRC_NAME> "${srcname}" objpath3 "${objpath2}") 15 16 list(APPEND objlist "\"${objpath3}\"") 17 endforeach() # (srcname ${sources}) 18 endforeach() 19 ocv_list_filterout(objlist jmemansi) # <<= dirty fix 20 endmacro()
之后编译模拟器用的类库时候遇到个C99编译问题 "implicit declaration of function ‘close‘ is invalid in C99"
解决方案:在platforms/ios/build_framework.py中 添加-DCMAKE_C_FLAGS=\"-Wno-implicit-function-declaration\"
1 cmakeargs = ("-GXcode " + 2 "-DCMAKE_BUILD_TYPE=Release " + 3 "-DCMAKE_C_FLAGS=\"-Wno-implicit-function-declaration\" " + 4 "-DCMAKE_TOOLCHAIN_FILE=%s/platforms/ios/cmake/Toolchains/Toolchain-%s_Xcode.cmake " + 5 "-DBUILD_opencv_world=ON " + 6 "-DCMAKE_INSTALL_PREFIX=install") % (srcroot, target)
记录之~~~~