Skip to content

When creating a framework for VisionOS, specifying "--dynamic" argument causes a build error. #25228

@utibenkei

Description

@utibenkei

System Information

OpenCV version: 4.9.0
Operating System / Platform: macOS ventura13.6.1
Compiler & compiler version: Cmake 3.28.1
Xcode version: 15.2

Detailed description

I get a build error when I specify the "--dynamic" argument to build_xcframework.py to build a dynamic framework for VisionOS.
If "--dynamic" argument is not specified, the build will succeed without problems. Or, if "--without=videoio" is specified, the build will also succeed without problems.

error log

ld: Undefined symbols:
  MatToUIImage(cv::Mat const&), referenced from:
      +[MatConverters converMatToUIImage:] in opencv2[94](MatConverters.o)
  UIImageToMat(UIImage const*, cv::Mat&, bool), referenced from:
      +[MatConverters convertUIImageToMat:alphaExist:] in opencv2[94](MatConverters.o)
  cv::create_AVFoundation_capture_cam(int), referenced from:
      __GLOBAL__sub_I_videoio_registry.cpp in libopencv_world.a[640](videoio_registry.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
============================================================
ERROR: Command '['clang++', '-Xlinker', '-rpath', '-Xlinker', '/usr/lib/swift', '-target', 'arm64-apple-darwin', '-isysroot', '/Applications/Xcode15.2.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.0.sdk', '-iframework', '/Applications/Xcode15.2.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.0.sdk/System/iOSSupport/System/Library/Frameworks', '-framework', 'AVFoundation', '-framework', 'CoreGraphics', '-framework', 'CoreImage', '-framework', 'CoreMedia', '-framework', 'QuartzCore', '-framework', 'Accelerate', '-framework', 'UIKit', '-framework', 'CoreVideo', '-install_name', '@rpath/opencv2.framework/opencv2', '-dynamiclib', '-dead_strip', '-fobjc-link-runtime', '-all_load', '-o', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/opencv2.framework/opencv2', '-L/Applications/Xcode15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/xros', '-L/usr/lib/swift', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/lib/Release/opencv2.framework/opencv2', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/libopencv_world.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/liblibpng.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/liblibwebp.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/liblibprotobuf.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/libade.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/libzlib.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/liblibjpeg-turbo.a']' returned non-zero exit status 1.
============================================================
Traceback (most recent call last):
  File "/Users/aaaaa/opencv/opencv/platforms/ios/build_framework.py", line 181, in build
    self._build(outdir)
  File "/Users/aaaaa/opencv/opencv/platforms/ios/build_framework.py", line 144, in _build
    self.makeDynamicLib(main_build_dir)
  File "/Users/aaaaa/opencv/opencv/platforms/ios/build_framework.py", line 389, in makeDynamicLib
    execute([
  File "/Users/aaaaa/opencv/opencv/platforms/apple/cv_build_utils.py", line 13, in execute
    retcode = check_call(cmd, cwd = cwd)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['clang++', '-Xlinker', '-rpath', '-Xlinker', '/usr/lib/swift', '-target', 'arm64-apple-darwin', '-isysroot', '/Applications/Xcode15.2.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.0.sdk', '-iframework', '/Applications/Xcode15.2.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.0.sdk/System/iOSSupport/System/Library/Frameworks', '-framework', 'AVFoundation', '-framework', 'CoreGraphics', '-framework', 'CoreImage', '-framework', 'CoreMedia', '-framework', 'QuartzCore', '-framework', 'Accelerate', '-framework', 'UIKit', '-framework', 'CoreVideo', '-install_name', '@rpath/opencv2.framework/opencv2', '-dynamiclib', '-dead_strip', '-fobjc-link-runtime', '-all_load', '-o', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/opencv2.framework/opencv2', '-L/Applications/Xcode15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/xros', '-L/usr/lib/swift', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/lib/Release/opencv2.framework/opencv2', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/libopencv_world.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/liblibpng.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/liblibwebp.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/liblibprotobuf.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/libade.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/libzlib.a', '/Users/aaaaa/opencv/visionostest/visionos/build/build-arm64-xros/install/lib/3rdparty/liblibjpeg-turbo.a']' returned non-zero exit status 1.
============================================================
ERROR: Command '['python3', '/Users/aaaaa/opencv/opencv/platforms/ios/build_visionos_framework.py', 'visionostest/visionos', '--visionos_archs', 'arm64', '--framework_name', 'opencv2', '--build_only_specified_archs', '--dynamic']' returned non-zero exit status 1.
============================================================
Traceback (most recent call last):
  File "/Users/aaaaa/opencv/./opencv/platforms/apple/build_xcframework.py", line 110, in <module>
    execute(command, cwd=os.getcwd())
  File "/Users/aaaaa/opencv/opencv/platforms/apple/cv_build_utils.py", line 13, in execute
    retcode = check_call(cmd, cwd = cwd)
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['python3', '/Users/aaaaa/opencv/opencv/platforms/ios/build_visionos_framework.py', 'visionostest/visionos', '--visionos_archs', 'arm64', '--framework_name', 'opencv2', '--build_only_specified_archs', '--dynamic']' returned non-zero exit status 1.

Steps to reproduce

1.git clone https://github.com/opencv/opencv.git
2../opencv/platforms/apple/build_xcframework.py --out visionostest --visionos_archs arm64 --visionsimulator_archs x86_64 --build_only_specified_archs --dynamic

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions