Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building OpenCV for IOS fails w/ code signing error #14374

Open
Chandler opened this issue Apr 20, 2019 · 9 comments
Open

Building OpenCV for IOS fails w/ code signing error #14374

Chandler opened this issue Apr 20, 2019 · 9 comments

Comments

@Chandler
Copy link

Chandler commented Apr 20, 2019

System information (version)
  • OpenCV => 4.1.0
  • Operating System / Platform => MacOS 10.14.4
  • XCode => 10.2.1
  • Compiler => AppleClang 10.0.1.10010046
  • Cmake => 3.5.2
Detailed description

Building OpenCV 4.1.0 for IOS fails. The error that sticks out the most is from
build/build-arm64-iphoneos/CMakeFiles/CMakeError.log (attached) and it states:

error: An empty identity is not valid when signing a binary for the product type 'Application'

There is another error in the stdout (attached) that might be related but seems like a red-herring

CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:188 (message):
  OpenCV 4.x requires C++11

It should be noted that the OSX build doesn't not have this issue on my machine, only the IOS one.

Thanks in advance for the help.

Steps to reproduce
cd $CODE/opencv
git checkout tags/4.1.0

mkdir -p $CODE/opencvbuild

python $CODE/opencv/platforms/ios/build_framework.py \
 	--iphoneos_deployment_target 12.2 \
 	--iphoneos_archs arm64 \
	--opencv $CODE/opencv \
	$CODE/opencvbuild

STDOUT

Using IPHONEOS_DEPLOYMENT_TARGET=12.2
Using iPhoneOS ARCHS=['arm64']
Using iPhoneSimulator ARCHS=['i386', 'x86_64']
Executing: ['cmake', '-GXcode', '-DAPPLE_FRAMEWORK=ON', '-DCMAKE_INSTALL_PREFIX=install', '-DCMAKE_BUILD_TYPE=Release', '-DOPENCV_INCLUDE_INSTALL_PATH=include', '-DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty', '-DIOS_ARCH=arm64', '-DCMAKE_TOOLCHAIN_FILE=/Users/cbabraham/code/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake', '-DCPU_BASELINE=DETECT', '/Users/cbabraham/code/opencv', '-DCMAKE_C_FLAGS=-fembed-bitcode', '-DCMAKE_CXX_FLAGS=-fembed-bitcode'] in /Users/cbabraham/code/opencvbuild/build/build-arm64-iphoneos
Executing: cmake -GXcode -DAPPLE_FRAMEWORK=ON -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_INCLUDE_INSTALL_PATH=include -DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty -DIOS_ARCH=arm64 -DCMAKE_TOOLCHAIN_FILE=/Users/cbabraham/code/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake -DCPU_BASELINE=DETECT /Users/cbabraham/code/opencv -DCMAKE_C_FLAGS=-fembed-bitcode -DCMAKE_CXX_FLAGS=-fembed-bitcode
-- Setting up iPhoneOS toolchain for IOS_ARCH='arm64'
-- iPhoneOS toolchain loaded
-- Setting up iPhoneOS toolchain for IOS_ARCH='arm64'
-- iPhoneOS toolchain loaded
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- The C compiler identification is AppleClang 10.0.1.10010046
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - failed
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - failed
-- Performing Test HAVE_CXX11 (check file: cmake/checks/cxx11.cpp)
-- Performing Test HAVE_CXX11 - Failed
CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:188 (message):
  OpenCV 4.x requires C++11
Call Stack (most recent call first):
  CMakeLists.txt:160 (include)


-- Configuring incomplete, errors occurred!
See also "opencvbuild/build/build-arm64-iphoneos/CMakeFiles/CMakeOutput.log".
See also "opencvbuild/build/build-arm64-iphoneos/CMakeFiles/CMakeError.log".
opencvbuild/build/build-arm64-iphoneos/CMakeFiles/CMakeError.log
Detecting CXX compiler ABI info failed to compile with the following output:
Change Dir: opencvbuild/build/build-arm64-iphoneos/CMakeFiles/CMakeTmp

Run Build Command:"opencvbuild/build/build-arm64-iphoneos/xcodebuild_wrapper" "-project" "CMAKE_TRY_COMPILE.xcodeproj" "build" "-target" "cmTC_f2f02" "-configuration" "Debug"
Build settings from command line:
    ARCHS = arm64
    IPHONEOS_DEPLOYMENT_TARGET = 12.2
    SDKROOT = iphoneos12.2

note: Using new build system
note: Planning build
note: Constructing build description
Build system information
error: An empty identity is not valid when signing a binary for the product type 'Application'. (in target 'cmTC_f2f02')
@Chandler
Copy link
Author

Chandler commented Apr 20, 2019

related: realm/jazzy#1057

@Chandler
Copy link
Author

Chandler commented Apr 20, 2019

The code signing error can be addressed w/ a hack by changing

https://github.com/opencv/opencv/blob/master/platforms/ios/cmake/Toolchains/xcodebuild_wrapper.in#L19

to include the arg CODE_SIGNING_ALLOWED=NO

But the build proceeds to another error, which is similar to
#12646

error: Build input file cannot be found: '/Users/cbabraham/code/opencvbuild/build/build-arm64-iphoneos/modules/world/opencl_kernels_ximgproc.cpp'

** BUILD FAILED **
The following build commands failed:
	CompileC /Users/cbabraham/code/opencvbuild/build/build-arm64-iphoneos/modules/world/OpenCV.build/Release-iphoneos/opencv_world.build/Objects-normal/arm64/opencl_kernels_ximgproc.o /Users/cbabraham/code/opencvbuild/build/build-arm64-iphoneos/modules/world/opencl_kernels_ximgproc.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

@Chandler
Copy link
Author

Chandler commented Apr 20, 2019

The 'input file cannot be found' error can be addressed by adding
-UseModernBuildSystem=NO to the list of args found here

@Chandler
Copy link
Author

Chandler commented Apr 20, 2019

FYI after fixing the above two issues, the build proceeded to this error:

Usage: /usr/local/bin/libtool [OPTION]... [MODE-ARG]...
Try 'libtool --help' for more information.
libtool:   error: unrecognised option: '-static'
============================================================
ERROR: Command '['libtool', '-static', '-o', '/Users/cbabraham/code/opencvbuild/build/build-arm64-iphoneos/lib/Release/libopencv_merged.a', ...... 

Which was fixed by this solution that unlinks a homebrew version of libtool
nodejs/node#2341 (comment)

The IOS build of OpenCV then runs to completion 🎉 🎉 🎉

@Bharathsrinivasan
Copy link

After fixing this issue
#14374 (comment)
you might encounter the following issue, if you are building with opencv_contrib repository.
opencv/opencv_contrib#1427 (comment)
It can be fixed by the steps mentioned by alalek in that link.

@AlvarHHM
Copy link

I encounter another singing error when building version 4.1.1


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:  
Build flags: -fembed-bitcode
Id flags:  

The output was:
65
note: Using new build system
note: Planning build
note: Constructing build description
error: Signing for "CompilerIdCXX" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'CompilerIdCXX' from project 'CompilerIdCXX')
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'CompilerIdCXX' from project 'CompilerIdCXX')

** BUILD FAILED **



Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
65
note: Using new build system
note: Planning build
note: Constructing build description
error: Signing for "CompilerIdCXX" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'CompilerIdCXX' from project 'CompilerIdCXX')
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'CompilerIdCXX' from project 'CompilerIdCXX')

** BUILD FAILED **



Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:  
Build flags: -fembed-bitcode
Id flags:  

The output was:
65
note: Using new build system
note: Planning build
note: Constructing build description
error: Signing for "CompilerIdC" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'CompilerIdC' from project 'CompilerIdC')
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'CompilerIdC' from project 'CompilerIdC')

** BUILD FAILED **



Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
65
note: Using new build system
note: Planning build
note: Constructing build description
error: Signing for "CompilerIdC" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'CompilerIdC' from project 'CompilerIdC')
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'CompilerIdC' from project 'CompilerIdC')

** BUILD FAILED **

@errollgarner
Copy link

I have the same error as @AlvarHHM reports. Config is:
OpenCV => 4.2.0
Operating System / Platform => MacOS 10.15.3
XCode => 11.3.1
Compiler => AppleClang 11.0.0
Cmake => 3.10.0

Setting CODE_SIGNING_ALLOWED=NO, as @Chandler suggests doesn't change outcome.

@hudrima1
Copy link

Hi,
I can't use the prebuilt iOS framework because it doesn't contain the contribs.
I also gave up with the Toolchainfile from within the OpenCV distribution and also the python
build script. It contains an error in my opinion.

I use this toolchain file: https://github.com/leetal/ios-cmake/blob/master/ios.toolchain.cmake
And I wrote a shell script with direct cmake calls. https://github.com/cpvrlab/SLProject/blob/develop/externals/prebuild_scripts/build_opencv_w_contrib_for_iosV8.sh

You can call it with the OpenCV version tag that you want.
E.g.: ./build_opencv_w_contrib_for_iosV8.sh 4.2.0

It clones OpenCV and OpenCV_Contribs.
Afterwards, it creates the build folder with cmake and starts compiling the modules but ends with an error not finding a source file!
At least it starts compiling.

@suxinde2009
Copy link

suxinde2009 commented Oct 22, 2020

This issue still exists. I try to build the v4.4.0 iOS framework with the python script, but failed. The error log is as below:

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:  
Build flags: -fembed-bitcode
Id flags:  

The output was:
65
note: Using new build system
note: Planning build
note: Constructing build description
error: Signing for "CompilerIdCXX" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'CompilerIdCXX' from project 'CompilerIdCXX')
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'CompilerIdCXX' from project 'CompilerIdCXX')

** BUILD FAILED **



Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
65
note: Using new build system
note: Planning build
note: Constructing build description
error: Signing for "CompilerIdCXX" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'CompilerIdCXX' from project 'CompilerIdCXX')
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'CompilerIdCXX' from project 'CompilerIdCXX')

** BUILD FAILED **



Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:  
Build flags: -fembed-bitcode
Id flags:  

The output was:
65
note: Using new build system
note: Planning build
note: Constructing build description
error: Signing for "CompilerIdC" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'CompilerIdC' from project 'CompilerIdC')
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'CompilerIdC' from project 'CompilerIdC')

** BUILD FAILED **



Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:  
Build flags: 
Id flags:  

The output was:
65
note: Using new build system
note: Planning build
note: Constructing build description
error: Signing for "CompilerIdC" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'CompilerIdC' from project 'CompilerIdC')
warning: Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO. (in target 'CompilerIdC' from project 'CompilerIdC')

** BUILD FAILED **

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants