2013-04-10 29 views
5

Tôi gặp sự cố khi xây dựng khung.Không thể xây dựng khung OpenCV cho iOS

Tôi đã nhân bản một bản sao của OpenCV từ đây: https://github.com/Itseez/opencv

Sau đó kiểm tra rằng tôi có cmake mới nhất 2.8.10.2

Sau đó chạy build_framework.py trong thư mục iOS.

ví dụ:

./opencv/ios/build_framework.py opencv-ios-build 

Output từ này là:

-- Setting up iPhoneOS toolchain 
-- iPhoneOS toolchain loaded 
-- Setting up iPhoneOS toolchain 
-- iPhoneOS toolchain loaded 
-- The CXX compiler identification is Clang 4.2.0 
-- The C compiler identification is Clang 4.2.0 
-- Detecting CXX compiler ABI info 
-- Detecting CXX compiler ABI info - failed 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - failed 
-- Performing Test HAVE_CXX_W 
-- Performing Test HAVE_CXX_W - Failed 
-- Performing Test HAVE_C_W 
-- Performing Test HAVE_C_W - Failed 
-- Performing Test HAVE_CXX_WALL 
-- Performing Test HAVE_CXX_WALL - Failed 
-- Performing Test HAVE_C_WALL 
-- Performing Test HAVE_C_WALL - Failed 
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE 
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Failed 
-- Performing Test HAVE_C_WERROR_RETURN_TYPE 
-- Performing Test HAVE_C_WERROR_RETURN_TYPE - Failed 
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR 
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR - Failed 
... 

-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.0") 
-- Performing Test HAVE_CXX_WNO_UNDEF 
-- Performing Test HAVE_CXX_WNO_UNDEF - Failed 
-- Performing Test HAVE_CXX_WNO_SIGN_PROMO 
-- Performing Test HAVE_CXX_WNO_SIGN_PROMO - Failed 
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS 
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS - Failed 
-- Performing Test HAVE_CXX_WNO_MISSING_PROTOTYPES 
-- Performing Test HAVE_CXX_WNO_MISSING_PROTOTYPES - Failed 
-- Performing Test HAVE_OBJCXX_FOBJC_EXCEPTIONS 
-- Performing Test HAVE_OBJCXX_FOBJC_EXCEPTIONS - Failed 
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS 
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS - Failed 
-- 
-- General configuration for OpenCV 2.4.9 ===================================== 
-- Version control:    unknown 
-- 
-- Platform: 
--  Host:      Darwin 12.3.0 i386 
--  Target:      iOS 
--  CMake:      2.8.10.2 
--  CMake generator:    Xcode 
--  CMake build tool:   /Applications/CMake 2.8-10.app/Contents/bin/cmakexbuild 
--  Xcode:      4.6.1 
-- 
-- C/C++: 
--  Built as dynamic libs?:  NO 
--  C++ Compiler:    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ (ver 4.2.0) 
--  C++ flags (Release):   -stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden -fPIC -DNDEBUG -O3 -fomit-frame-pointer -ffast-math -DNDEBUG 
--  C++ flags (Debug):   -stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden -fPIC -g -O0 -DDEBUG -D_DEBUG -ggdb3 
--  C Compiler:     /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 
--  C flags (Release):   -fPIC -O3 -DNDEBUG -DNDEBUG 
--  C flags (Debug):    -fPIC -g -O0 -DDEBUG -D_DEBUG -ggdb3 
--  Linker flags (Release):  
--  Linker flags (Debug):   
--  Precompiled headers:   NO 
-- 
-- OpenCV modules: 
--  To be built:     core imgproc flann highgui features2d calib3d ml video objdetect contrib legacy nonfree photo softcascade stitching videostab world 
--  Disabled:     - 
--  Disabled by dependency:  - 
--  Unavailable:     androidcamera gpu java ocl python superres ts 
-- 
-- GUI: 
--  Cocoa:      YES 
--  OpenGL support:    NO 
-- 
-- 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 
-- 
-- Other third-party libraries: 
--  Use IPP:      NO 
--  Use Eigen:     NO 
--  Use TBB:      NO 
--  Use OpenMP:     NO 
--  Use GCD      YES 
--  Use Concurrency    NO 
--  Use C=:      NO 
--  Use Cuda:     NO 
--  Use OpenCL:     NO 
-- 
-- Python: 
--  Interpreter:     NO 
-- 
-- Java: 
--  ant:       NO 
--  JNI:       NO 
--  Java tests:     NO 
-- 
-- Documentation: 
--  Build Documentation:   NO 
--  Sphinx:      NO 
--  PdfLaTeX compiler:   NO 
-- 
-- Tests and samples: 
--  Tests:      NO 
--  Performance tests:   NO 
--  C/C++ Examples:    NO 
-- 
-- Install path:     /Users/Ants/Dev/iOS/opencv-ios-build/build/iPhoneOS-armv7/install 
-- 
-- cvconfig.h is in:    /Users/Ants/Dev/iOS/opencv-ios-build/build/iPhoneOS-armv7 
-- ----------------------------------------------------------------- 
-- 
-- Configuring done 
-- Generating done 
-- Build files have been written to: /Users/Ants/Dev/iOS/opencv-ios-build/build/iPhoneOS-armv7 

Nhưng nó xây dựng các dự án Xcode.

Quá trình này tiếp tục chạy biên dịch nhưng điều này không thành công trên rand.cpp trong lõi opencv

/Users/Ants/Dev/iOS/opencv/modules/core/src/rand.cpp:758:8: error: unknown type name 'pthread_key_t'; did you mean 'pthread_attr_t'? 
static pthread_key_t tlsRNGKey = 0; 
     ^~~~~~~~~~~~~ 
     pthread_attr_t 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/sys/signal.h:157:34: note: 'pthread_attr_t' declared here 
typedef __darwin_pthread_attr_t   pthread_attr_t; 
             ^
/Users/Ants/Dev/iOS/opencv/modules/core/src/rand.cpp:758:22: error: no viable conversion from 'int' to 'pthread_attr_t' (aka '_opaque_pthread_attr_t') 
static pthread_key_t tlsRNGKey = 0; 
        ^   ~ 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/sys/_types.h:64:8: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const _opaque_pthread_attr_t &' for 1st argument 
struct _opaque_pthread_attr_t { long __sig; char __opaque[__PTHREAD_ATTR_SIZE__]; }; 
    ^
/Users/Ants/Dev/iOS/opencv/modules/core/src/rand.cpp:759:8: error: unknown type name 'pthread_once_t'; did you mean 'pthread_attr_t'? 
static pthread_once_t tlsRNGKeyOnce = PTHREAD_ONCE_INIT; 
     ^~~~~~~~~~~~~~ 
     pthread_attr_t 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/sys/signal.h:157:34: note: 'pthread_attr_t' declared here 
typedef __darwin_pthread_attr_t   pthread_attr_t; 
             ^
/Users/Ants/Dev/iOS/opencv/modules/core/src/rand.cpp:759:39: error: use of undeclared identifier 'PTHREAD_ONCE_INIT' 
static pthread_once_t tlsRNGKeyOnce = PTHREAD_ONCE_INIT; 
            ^
/Users/Ants/Dev/iOS/opencv/modules/core/src/rand.cpp:774:5: error: use of undeclared identifier 'pthread_once' 
    pthread_once(&tlsRNGKeyOnce, makeRNGKey); 
    ^
5 errors generated. 

Bất kỳ ý tưởng?

+0

BTW Tôi có thể sử dụng cmake để xây dựng thư viện OSX mà không gặp bất kỳ sự cố nào. – Ants

Trả lời

1

Dường như bạn đang thiếu các thư viện cho pthreads, hoặc có thể là #include

Bài viết này đưa ra một cái nhìn tổng quan tốt của việc sử dụng chúng trong OS X. http://www.drdobbs.com/parallel/mastering-threads-on-macos-x/232602177

+0

Tôi đã nghĩ rằng đó là vì một cái gì đó không hoạt động cho kịch bản xây dựng iOS. – Ants

2

Các đầu mối là ở dòng:

-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.0")

tôi làm việc này bằng cách chỉnh sửa các tập tin build_framework.py, thêm đường dẫn đến python vào cmakeargs phần (circa line 39):

cmakeargs = ("-GXcode " + 
      "-DPYTHON_EXECUTABLE=/usr/bin/python " + 
      "-DCMAKE_BUILD_TYPE=Release " + 
      "-DCMAKE_TOOLCHAIN_FILE=%s/ios/cmake/Toolchains/Toolchain-%s_Xcode.cmake" + 
      "-DBUILD_opencv_world=ON " + 
      "-DCMAKE_INSTALL_PREFIX=install") % (srcroot, target) 

Cách khác (và nhanh hơn so với biên dịch từ đầu) sử dụng cocoapods để cài đặt phụ thuộc thay thế.

+0

cảm ơn tôi sẽ thử điều này và cập nhật sau đó. Tôi thích ý tưởng sử dụng cocoapods. – Ants

Các vấn đề liên quan