【问题标题】:"string.h" not found message in building qt app for iOS在为 iOS 构建 qt 应用程序时找不到“string.h”消息
【发布时间】:2019-03-24 04:40:34
【问题描述】:

我最近将 Xcode 更新到 10.0 版,之后当我尝试为 iOS 构建版本时,我遇到了以下问题。

1:04:17:Diasteca 项目的运行步骤... 11:04:17:开始:“/Users/belladellifabio/Qt/5.11.1/ios/bin/qmake”/Users/belladellifabio/Desktop/QtProjects/Diasteca/mqtt_test/mqtt_test.pro -spec macx-ios-clang CONFIG+ =iphoneos CONFIG+=设备配置+=qml_debug 项目消息:该项目使用私有头文件,因此将绑定到这个特定的 Qt 模块构建版本。 项目消息:针对其他版本的 Qt 模块运行此项目可能会在任意点崩溃。 项目消息:这不是错误,而是使用 Qt 内部的结果。你被警告了! 11:04:18:进程“/Users/belladellifabio/Qt/5.11.1/ios/bin/qmake”正常退出。 11:04:18:开始:“/usr/bin/make”qmake_all make: 对 `qmake_all' 无事可做。 11:04:18:进程“/usr/bin/make”正常退出。 11:04:18:开始:“/usr/bin/make” /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -fPIC -std=gnu++11 -arch arm64 -arch x86_64 -Xarch_arm64 - miphoneos-version-min=12.0 -Xarch_arm64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk -Xarch_x86_64 -mios-simulator-version-min=12.0 - Xarch_x86_64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk -fobjc-nonfragile-abi -fobjc-legacy-dispatch -fembed-bitcode-marker -Wall - W -DQT_COMPILER_SUPPORTS_SSE2 -DMQTT_TEST_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../Diasteca/mqtt_test -I. -I../../../../Qt/5.11.1/ios/mkspecs/common/uikit -I../../../../Qt/5.11.1/ios/include -I../../../../Qt/5.11.1/ios/include/QtNetwork -I../../../../Qt/5.11.1/ios/include/QtCore /5.11.1 -I../../../../Qt/5.11.1/ios/include/QtCore/5.11.1/QtCore -I../../../../Qt /5.11.1/ios/include/QtCore -I。 -I../../../../Qt/5.11.1/ios/mkspecs/macx-ios-clang -o qmqttclient.o ../../Diasteca/mqtt_test/qmqttclient.cpp clang:警告:没有这样的 sysroot 目录:'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk' [-Wmissing-sysroot] clang:警告:没有这样的 sysroot 目录:'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk' [-Wmissing-sysroot] 在 ../../Diasteca/mqtt_test/qmqttclient.cpp:30 包含的文件中: 在 ../../Diasteca/mqtt_test/qmqttclient.h:33 包含的文件中: 在 ../../Diasteca/mqtt_test/qmqttglobal.h:33 包含的文件中: 在 ../../../../Qt/5.11.1/ios/include/QtCore/qglobal.h:47 包含的文件中: 在 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:202 包含的文件中: 在 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:61 包含的文件中: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:61:15:致命错误:找不到'string.h'文件

可能真正的问题不是找不到文件错误,而是与 qty 尝试使用系统上不再安装的 SDK 构建应用程序的事实有关。这是qt问题吗?如何指定用于构建应用程序的 iOS SDK 版本?有可能吗?

【问题讨论】:

  • 来自您的错误消息:“针对其他版本的 Qt 模块运行此项目可能会在任意点崩溃。这不是错误,而是使用 Qt 内部的结果。您已被警告! "
  • @Yksisarvinen 看起来这是一个弃用错误...

标签: c++ ios xcode qt build


【解决方案1】:

最后,我找到并删除了 .qmake.cache 和 .qmake.stash 文件。我已经重新启动了 QtCreator,现在它似乎可以工作了。

【讨论】:

  • 这真的很有帮助!
【解决方案2】:

Qt 将 SDK 信息存储在构建输出和 .pro.user 文件的深处。 删除用户文件(如果您有自定义构建步骤,您可能需要备份您的用户文件)、完整(影子)构建树并修改您的 .pro 文件,以便没有像 QMAKE_MAC_SDK = macosx10.13 这样的行。

然后调用 qmake 重新构建你的项目,不一致应该没有了。

【讨论】:

  • 我试过了,但似乎没有任何效果。 Qt 搜索旧的 SDK。有人知道手动配置 SDK 路径的方法吗?
【解决方案3】:

当 Qt 期望的 iOS SDK 与您安装的 iOS SDK 不同时,会发生这种情况。例如 Qt 5.13.1 需要 iPhoneOS13.1.sdk 但我的 Xcode 目前有 iPhoneOS13.2.sdk:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x  7 root  wheel  224 Nov  5  2019 iPhoneOS.sdk
lrwxr-xr-x  1 root  wheel   12 Jan 15  2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x  8 root  wheel  256 Jul 22 14:14 iPhoneSimulator.sdk
lrwxr-xr-x  1 root  wheel   19 Jan 15  2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk

为了解决这个问题,我们可以让 Qt 使用 iPhoneOS13.2.sdk:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x  7 root  wheel  224 Nov  5  2019 iPhoneOS.sdk
lrwxr-xr-x  1 root  wheel   12 Jan 15  2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk
$ sudo ln -s iPhoneOS.sdk iPhoneOS13.1.sdk
$ ls -l
total 0
drwxrwxr-x  8 root  wheel  256 Jul 22 14:20 iPhoneOS.sdk
lrwxr-xr-x  1 root  wheel   12 Jul 22 14:20 iPhoneOS13.1.sdk -> iPhoneOS.sdk
lrwxr-xr-x  1 root  wheel   12 Jan 15  2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
$ ls -l
total 0
drwxrwxr-x  8 root  wheel  256 Jul 22 14:14 iPhoneSimulator.sdk
lrwxr-xr-x  1 root  wheel   19 Jan 15  2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk
$ sudo ln -s iPhoneSimulator.sdk iPhoneSimulator13.1.sdk
$ ls -l
total 0
drwxrwxr-x  8 root  wheel  256 Jul 22 14:14 iPhoneSimulator.sdk
lrwxr-xr-x  1 root  wheel   19 Jul 22 14:39 iPhoneSimulator13.1.sdk -> iPhoneSimulator.sdk
lrwxr-xr-x  1 root  wheel   19 Jan 15  2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk

【讨论】:

    猜你喜欢
    • 2013-09-04
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 1970-01-01
    • 1970-01-01
    • 2011-06-18
    • 2013-07-02
    • 2020-02-01
    相关资源
    最近更新 更多