Ask Your Question

opencv ios7 installation issue

asked 2014-01-13 02:52:26 -0500

Khawar gravatar image

I have been trying to install openCV for iOS but badly stuck. I downloaded opencv, wrote these lines in terminal

cd / sudo ln -s /Applications/ Developer

Then installed cmake and wrote this in terminal cd ~/<my_working_directory> python opencv/platforms/ios/ ios

The initials tests all failed in the terminal displaying

-- The CXX compiler identification is Clang 5.0.0 -- The C compiler identification is Clang 5.0.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - failed -- Detecting C compiler ABI info -- Detecting C compiler ABI info - failed

but in the end it said that its configured. Now the opencv2.framework file is basically empty. When I add the framework to xcode project, it give linker error stating: linker command failed with exit code 1 (use -v to see invocation) ld: framework not found opencv2

Please help, i am super stuck

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-01-20 09:50:50 -0500

bskrt gravatar image

updated 2014-01-20 09:52:18 -0500

I managed to "fix" this (more like a hack really) by combining a couple of stackoverflow answers.

The issue I was having when following the building procedure you describe was related to "jmemansi.o" not being found. Following this tip fixed that issue.

Filtering out jmemansi.o from the linker input in modules/world/CMakeLists.txt:84:

Add ocv_list_filterout(objlist jmemansi) # <<= dirty fix

  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}")

      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})
  ocv_list_filterout(objlist jmemansi) # <<= dirty fix

The next issue I had was related to zlib:

implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (close(state->fd) == -1)

I fixed this with this answer:

Add -Wno-implicit-function-declaration to your C_FLAGS ... this can be added to in the cmakeargs list as -DCMAKE_C_FLAGS=\"-Wno-implicit-function-declaration\"

cmakeargs = ("-GXcode " +
        "-DCMAKE_BUILD_TYPE=Release " +
        "-DCMAKE_C_FLAGS=\"-Wno-implicit-function-declaration\" " +
        "-DCMAKE_TOOLCHAIN_FILE=%s/platforms/ios/cmake/Toolchains/Toolchain-%s_Xcode.cmake " +
        "-DBUILD_opencv_world=ON " +
        "-DCMAKE_INSTALL_PREFIX=install") % (srcroot, target)

After those 2 dirty hacks everything built properly! Hope this helps, good luck!

(for reference: I built it on osx 10.9 on with xcode 5 command line tools) btw: most tests all seem to fail, but it works anyway, no clue why that's happening.

edit flag offensive delete link more


Just add a comment to share that I had the same issues to build the framework from source but following your hacks it worked.

mccpower gravatar imagemccpower ( 2014-01-21 05:36:08 -0500 )edit

Question Tools


Asked: 2014-01-13 02:52:26 -0500

Seen: 769 times

Last updated: Jan 20 '14