首页 > 解决方案 > iOS原生sdk中导入的QT库

问题描述

所以这个项目的计划是有一个可以在原生 SDK 中使用的 QT 库。我们已经完成了一个模拟库,当在 QT 应用程序中导入到 xcodeproj 中时,它可以正常工作。

该库是静态的,运行 lipo -info 返回 x86_64 arm64。

我使用了来自https://alediaferia.com/2014/12/18/a-native-ios-app-with-a-qt-third-party-library/的教程,但卡住了。经过一番挖掘,我到达了发生链接的步骤,结果如下:

Undefined symbols for architecture arm64:
  "_pcre2_match_16", referenced from:
      safe_pcre2_match_16(pcre2_real_code_16 const*, unsigned short const*, int, int, int, pcre2_real_match_data_16*, pcre2_real_match_context_16*) in libQt5Core.a(qregularexpression.o)
  "_pcre2_match_context_create_16", referenced from:
      QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
  "_pcre2_jit_stack_assign_16", referenced from:
      QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
  "_pcre2_jit_stack_free_16", referenced from:
      QThreadStorage<QPcreJitStackPointer*>::deleteData(void*) in libQt5Core.a(qregularexpression.o)
  "_pcre2_get_ovector_pointer_16", referenced from:
      QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
  "_pcre2_match_data_free_16", referenced from:
      QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
  "_pcre2_config_16", referenced from:
      QRegularExpressionPrivate::getPatternInfo() in libQt5Core.a(qregularexpression.o)
  "_pcre2_pattern_info_16", referenced from:
      QRegularExpressionPrivate::getPatternInfo() in libQt5Core.a(qregularexpression.o)
      QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
  "_pcre2_jit_compile_16", referenced from:
      QRegularExpressionPrivate::optimizePattern() in libQt5Core.a(qregularexpression.o)
  "_pcre2_match_context_free_16", referenced from:
      QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
  "_pcre2_compile_16", referenced from:
      QRegularExpressionPrivate::compilePattern() in libQt5Core.a(qregularexpression.o)
  "_pcre2_code_free_16", referenced from:
      QRegularExpressionPrivate::~QRegularExpressionPrivate() in libQt5Core.a(qregularexpression.o)
      QRegularExpressionPrivate::compilePattern() in libQt5Core.a(qregularexpression.o)
  "_pcre2_jit_stack_create_16", referenced from:
      safe_pcre2_match_16(pcre2_real_code_16 const*, unsigned short const*, int, int, int, pcre2_real_match_data_16*, pcre2_real_match_context_16*) in libQt5Core.a(qregularexpression.o)
  "_pcre2_match_data_create_from_pattern_16", referenced from:
      QRegularExpressionPrivate::doMatch(QString const&, int, int, int, QRegularExpression::MatchType, QFlags<QRegularExpression::MatchOption>, QRegularExpressionPrivate::CheckSubjectStringOption, QRegularExpressionMatchPrivate const*) const in libQt5Core.a(qregularexpression.o)
  "_uncompress", referenced from:
      qUncompress(unsigned char const*, int) in libQt5Core.a(qbytearray.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

当前的链接器标志

项目的外观:

项目结构。

有谁知道发生了什么?

标签: c++swiftqtqml

解决方案


您缺少与 libqtpcre2 的链接

添加

-lqtpcre2 

进入 xcode 的“构建设置”中的“其他链接器标志”


推荐阅读