Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencv framework for iOS error

Tags:

c++

ios

opencv

I am trying to build the opencv framework for Xcode. I am new to the Mac world as well as opencv. I followed the instructions as given on

http://docs.opencv.org/doc/tutorials/introduction/ios_install/ios_install.html

I cloned the repository (opencv 2.4.7) and then tried running the python script - as per the instruction on the link

python opencv/platforms/ios/build_framework.py ios

I get the below error, can someone please help? I am using OSX 10.8.5

Applications/gebos_third_party_apps/opencv/3rdparty/zlib/gzwrite.c:84:15:

note: did you mean 'fwrite'? got = write(state->fd, strm->next_in, strm->avail_in); ^~~~~ fwrite In file included from /Applications/gebos_third_party_apps/opencv/3rdparty/zlib/gzwrite.c:6: In file included from /Applications/gebos_third_party_apps/opencv/3rdparty/zlib/gzguts.h:21:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/include/stdio.h:252:9:

note: 'fwrite' declared here size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict) __DARWIN_ALIAS(fwrite); ^ /Applications/gebos_third_party_apps/opencv/3rdparty/zlib/gzwrite.c:573:9: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (close(state->fd) == -1) ^ 2 errors generated.

** INSTALL FAILED **

The following build commands failed: CompileC /Applications/gebos_third_party_apps/ios/build/iPhoneSimulator-x86_64/3rdparty/zlib/OpenCV.build/Release-iphonesimulator/zlib.build/Objects-normal/x86_64/gzwrite.o

3rdparty/zlib/gzwrite.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler CompileC /Applications/gebos_third_party_apps/ios/build/iPhoneSimulator-x86_64/3rdparty/zlib/OpenCV.build/Release-iphonesimulator/zlib.build/Objects-normal/x86_64/gzlib.o 3rdparty/zlib/gzlib.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler CompileC /Applications/gebos_third_party_apps/ios/build/iPhoneSimulator-x86_64/3rdparty/zlib/OpenCV.build/Release-iphonesimulator/zlib.build/Objects-normal/x86_64/gzread.o 3rdparty/zlib/gzread.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (3 failures) Traceback (most recent call last): File "opencv-lib/opencv/platforms/ios/build_framework.py", line 112, in build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../..")), os.path.abspath(sys.argv[1])) File "opencv-lib/opencv/platforms/ios/build_framework.py", line 104, in build_framework put_framework_together(srcroot, dstroot) File "opencv-lib/opencv/platforms/ios/build_framework.py", line 80, in put_framework_together shutil.copytree(tdir0 + "/install/include/opencv2", dstdir + "/Headers") File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 168, in copytree names = os.listdir(src) OSError: [Errno 2] No such file or directory: '../build/iPhoneOS-arm64/install/include/opencv2'

like image 911
user3055567 Avatar asked Dec 16 '22 03:12

user3055567


1 Answers

Sadly, the best way around this, other than fixing the zlib warnings directly, is to add -Wno-implicit-function-declaration to your C_FLAGS ... this can added to build_framework.py 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)

.....

like image 133
Kaolin Fire Avatar answered Dec 27 '22 11:12

Kaolin Fire