程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了构建 ceres-solver 作为 Mac Catalyst 的静态库大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决构建 ceres-solver 作为 Mac Catalyst 的静态库?

开发过程中遇到构建 ceres-solver 作为 Mac Catalyst 的静态库的问题如何解决?下面主要结合日常开发的经验,给出你关于构建 ceres-solver 作为 Mac Catalyst 的静态库的解决方法建议,希望对你解决构建 ceres-solver 作为 Mac Catalyst 的静态库有所启发或帮助;

我正在尝试在最新的 Apple Silicon M1 芯片上为我们的 iOS 应用添加测试。@R_131_9616@程序对第​​ 3 方库的依赖之一是对 Ceres-Solver。我已经尝试了几天来为最新平台编译 ceres,但我所有的尝试都失败了。

所以我们使用 CMake 生成构建文件,然后我尝试使用 Xcode 和 xcodebuild 进行编译。构建成功,但每当我尝试将 libceres.a 库链接到@R_131_9616@程序时,我都会收到:

Building for Mac Catalyst,but the linked library 'libceresmacOs.a' was built for macOs. You may need to reStrict the platforms for which this library should be linked in the target editor,or replace it with an XCFramework that supports both platforms.

我觉得这很奇怪,因为我确实在 Xcode 中构建,并且在编译 ceres 和@R_131_9616@程序时我的目标是相同的平台(“我的 Mac”)。我的一个怀疑是我在 CMake 命令中设置了一些错误的标志,这就是我正在运行它

cmake $fileDir/ceres-solver \
  -G"$GENERATOR_name" \
  -DCMAKE_BUILD_TYPE=Release \
  -DENABLE_BITCODE=OFF \
  -DENABLE_ARC=OFF \
  -DCMAKE_INSTall_PREFIX=$fileDir/libs-macos \
  -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=TRUE \
  -DEIGENSPARSE=ON \
  -DEIGEN_INCLUDE_DIR_HINTS=$fileDir/eigen-git-mirror \
  -DEIGEN_INCLUDE_DIR=$fileDir/eigen-git-mirror \
  -DMINIGLOG=ON \
  -DCXX11_THREADS=ON \
  -dopENMP=OFF \
  -DTBB=OFF

我尝试为新的苹果目标添加标志: -DCMAKE_C_FLAGS="-target x86_64-apple-iOS13.0-macabi" 但这没有任何效果,因为当我检查输出时,我看到使用 -target arm64-apple-macos11.1 调用了 clang。 而且我在构建设置过程中也遇到错误:

 building for macOS-arm64 but attempTing to link with file built for unkNown-x86_64
    Undefined symbols for architecture arm64:
      "_main",referenced from:
         implicit entry/start for main executable
    ld: symbol(s) not found for architecture arm64

我也试过 xcodebuild -project "Ceres.xcodeproj" -configuration "Release" -scheR_918_11845@e "ceres" -desTination "platform=macOS,variant=Mac Catalyst" 但这给了我一个错误

xcodebuild: error: Unable to find a desTination matching the provIDed desTination specifIEr:
        { platform:macOS,variant:Mac Catalyst }

    Available desTinations for the "ceres" scheR_918_11845@e:
        { platform:macOS,arch:arm64,ID:00008103-001419A0029A001E }

    Ineligible desTinations for the "ceres" scheR_918_11845@e:
        { platform:macOS,name:Any Mac }

所以我在这里的想法不多了,如果有人能帮助我,我将不胜感激。 顺便提一下,我在 macOS Big Sur 11.1 上使用 Xcode 12.4 版

非常感谢

解决方法

经过更多研究后,我想出了如何进行这项工作,以防有人偶然发现同样的问题。 我最终阅读了这个问题描述 (link) 并让我觉得我应该尝试使用不同的代码生成器。 我的 cmake 配置是正确的,但显然使用 XCode 作为代码生成器存在错误(此处为 -G"$GENERATOR_NAME" )。设置 GENERATOR_NAME=Ninja 后,我设法编译了一个适用于 Mac Catalyst 的库版本。

大佬总结

以上是大佬教程为你收集整理的构建 ceres-solver 作为 Mac Catalyst 的静态库全部内容,希望文章能够帮你解决构建 ceres-solver 作为 Mac Catalyst 的静态库所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。