Ask Your Question

build opencv3.1 on mac for iOS failed

asked 2016-06-19 22:20:56 -0600

I had used cmkae to build opencv3.1 on my mac successes, and passed testing on python script. when I try to build the opencv framework for iOS ,it failed: my input build command is (version of python is 2.7.11):

python ../opencv/platforms/ios/ --opencv ../opencv/ --contrib ../opencv_contrib/ ./

the opencv path 、opencv_contrib path is correct。 the build error info is as following:


The following build commands failed: CompileC /Users/allenyang/openSourcePjt/opencv/opencv_ios_framwork/build/arm64-iPhoneOS/3rdparty/zlib/ 3rdparty/zlib/gzlib.c normal arm64 c (1 failure)

============================================================ ERROR: Command '['xcodebuild', 'IPHONEOS_DEPLOYMENT_TARGET=6.0', 'ARCHS=arm64', '-sdk', 'iphoneos', '-configuration', 'Release', '-parallelizeTargets', '-jobs', '4', '-target', 'ALL_BUILD', 'build']' returned non-zero exit status 65


Traceback (most recent call last): File "../opencv/platforms/ios/", line 87, in build self._build(outdir) File "../opencv/platforms/ios/", line 81, in _build self.buildOne(t[0], t[1], mainBD, cmake_flags) File "../opencv/platforms/ios/", line 139, in buildOne execute(buildcmd + ["-target", "ALL_BUILD", "build"], cwd = builddir) File "../opencv/platforms/ios/", line 34, in execute retcode = check_call(cmd, cwd = cwd) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 540, in check_call raise CalledProcessError(retcode, cmd) CalledProcessError: Command '['xcodebuild', 'IPHONEOS_DEPLOYMENT_TARGET=6.0', 'ARCHS=arm64', '-sdk', 'iphoneos', '-configuration', 'Release', '-parallelizeTargets', '-jobs', '4', '-target', 'ALL_BUILD', 'build']' returned non-zero exit status 65

It Seem that build for iPhone 6.0 is failed.. while the platform configured in is as following:

b = Builder(args.opencv, args.contrib,
        ("armv7", "iPhoneOS"),
        ("armv7s", "iPhoneOS"),
        ("arm64", "iPhoneOS"),
        ("i386", "iPhoneSimulator"),
        ("x86_64", "iPhoneSimulator"),

so ,it was failed when build for arm64 architecture。。。how to fix it?
my Xcode version is Version 7.3.1 (7D1014)

opencv version is 3.1.0

python version is 2.7.11

mac os version is 10.11.5

thanks a lot。。

edit retag flag offensive close merge delete


Same problem.

Setup: OpenCV 3.1.0 Python 2.7.10 Mac OS 10.11.5 XCode 7.3.1 (7D1014)

It builds okay for ARMv7 and ARMv7s. Incidentally, I am building it with opencv_contrib modules.

Spotted this error in the output: /Users/username/codespace/git/opencv/3rdparty/zlib/gzlib.c:256:24: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration] state->start = LSEEK(state->fd, 0, SEEK_CUR);

Melvin_DY gravatar imageMelvin_DY ( 2016-06-27 21:43:24 -0600 )edit

1 answer

Sort by » oldest newest most voted

answered 2016-06-27 22:20:06 -0600

Melvin_DY gravatar image

Based on the answer found here:

I added an #include '<'unistd.h'>' (remove the single quotes) in 3rdparty/zlib/gzguts.h. Compiles OK.

edit flag offensive delete link more


That single line, worked out the compilation process for me.

ajonnet gravatar imageajonnet ( 2016-09-24 03:46:04 -0600 )edit

it works for me (Y)

agustingandara gravatar imageagustingandara ( 2018-05-21 10:11:02 -0600 )edit

Question Tools



Asked: 2016-06-19 22:20:56 -0600

Seen: 1,434 times

Last updated: Jun 19 '16