C++ 错误:无法解析“macosx10.8”的 SDK 路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26320677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 11:34:51  来源:igfitidea点击:

Error: Could not resolve SDK path for 'macosx10.8'

c++qt

提问by Sebastian A

So I just installed qt around 5 minutes ago, and when I wanted to code a simple line of text in the Push Button and try to run it, I got this error:

所以我大约在 5 分钟前安装了 qt,当我想在 Push Button 中编写一行简单的文本并尝试运行它时,我收到了这个错误:

:-1: error: Could not resolve SDK path for 'macosx10.8'

:-1: 错误: 无法解析“macosx10.8”的 SDK 路径

Could anyone help? Also, if you need me to do something, could you explain like I'm five please. (Not actually like I"m five but I hope you know what i mean)

有人可以帮忙吗?另外,如果你需要我做点什么,你能不能像我五岁那样解释一下。(实际上不像我五岁,但我希望你明白我的意思)

回答by docsteer

The problem is that the online installer for Qt currently supports OSX 10.8 (Mountain Lion) by default, and I'm guessing you are on 10.9 (Mavericks) or greater.

问题是 Qt 的在线安装程序目前默认支持 OSX 10.8(Mountain Lion),我猜你是 10.9(Mavericks)或更高版本。

There is a workaround:

有一个解决方法:

  • Navigate to where you installed Qt (default /Users/your username/Qt) using finder
  • Go to the subdirectory 5.3/clang_64/mkspecs directory
  • Open the file called qdevice.pri with a text editor
  • Change the line !host_build:QMAKE_MAC_SDK = macosx10.8to:
    • !host_build:QMAKE_MAC_SDK = macosx10.9if you are on OS X 10.9 (Mavericks), or
    • !host_build:QMAKE_MAC_SDK = macosxif you are on OS X 10.10 (Yosemite)
  • Save the file and restart Qt Creator
  • 使用 finder 导航到您安装 Qt 的位置(默认/用户/您的用户名/Qt)
  • 进入子目录 5.3/clang_64/mkspecs 目录
  • 使用文本编辑器打开名为 qdevice.pri 的文件
  • 将该行更改 !host_build:QMAKE_MAC_SDK = macosx10.8为:
    • !host_build:QMAKE_MAC_SDK = macosx10.9如果您使用的是 OS X 10.9 (Mavericks),或者
    • !host_build:QMAKE_MAC_SDK = macosx如果您使用的是 OS X 10.10 (Yosemite)
  • 保存文件并重启 Qt Creator

回答by rsp1984

I'm running Qt 5.7.1 on Mac OS 10.12.2.

我在 Mac OS 10.12.2 上运行 Qt 5.7.1。

None of the above answers involving adding !host_build:QMAKE_MAC_SDK = macosx10.12to a file worked for me.

上述涉及添加!host_build:QMAKE_MAC_SDK = macosx10.12到文件的答案都不适合我。

What didwork was a small reconfigure on the XCode side of things as described here, the key step being entering

什么的工作是对事物的XCode侧的小重新配置所描述这里,关键的一步是进入

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

in the command line.

在命令行中。

What caused the problem for me was that I installed the XCode command line tools beforeinstalling XCode itself which apparently makes it hard for Qt to find the Mac OS SDK.

对我造成问题的原因是我安装 XCode之前安装了 XCode 命令行工具这显然使 Qt 很难找到 Mac OS SDK。

回答by Dylan_Larkin

add

添加

QMAKE_MAC_SDK = macosx10.12

to your .pro file. Done and Done. (for some, qdevice.pri does not contain the !host_build line, and adding it does nothing, so just set the variable directly in the .pro file).

到您的 .pro 文件。完成和完成。(对于某些人来说,qdevice.pri 不包含 !host_build 行,添加它没有任何作用,所以只需直接在 .pro 文件中设置变量)。

I have confirmed that you will eventually also have to implement this https://github.com/Homebrew/formula-patches/blob/master/qt5/xcrun-xcode-8.patch: which is just a matter of changing one line in your default_pre.prf file (for your appropriate machine aka Mac/PC, etc...)

我已经确认你最终还必须实现这个https://github.com/Homebrew/formula-patches/blob/master/qt5/xcrun-xcode-8.patch:这只是改变一行的问题您的 default_pre.prf 文件(适用于您的适当机器,又名 Mac/PC 等...)

回答by L.Clague

I recently upgraded from OSX 10.8 to 10.12 and ran into this using Qt 5.7

我最近从 OSX 10.8 升级到 10.12 并使用 Qt 5.7 遇到了这个问题

The issue was resolved by a combination of:

该问题已通过以下组合解决:

1) FranklinA's suggestion:

1) FranklinA 的建议:

Open Xcode->Preferences->Locations->command line tools..select the CLT xcode-select active developer directory error

打开Xcode->Preferences->Locations->command line tools..select CLT xcode-select active developer directory 错误

..and..

..和..

2) adding to the .pro file the following line: QMAKE_MAC_SDK = macosx10.12

2) 在 .pro 文件中添加以下行:QMAKE_MAC_SDK = macosx10.12

回答by timpwbaker

Coming to this late.

这么晚才来。

I had this error an all I needed to do was open up the actual Xcode app (which for some reason was not findable by spotlight but was in the applications folder), accept some terms, and let it do some config.

我遇到了这个错误,我需要做的就是打开实际的 Xcode 应用程序(由于某种原因无法通过聚光灯找到,但在应用程序文件夹中),接受一些条款,然后让它做一些配置。

回答by Fabio De Carli

For Qt 5.7 and macOS Sierra

对于 Qt 5.7 和 macOS Sierra

Navigate to where you installed Qt (default /Users/your username/Qt) using finder

使用 finder 导航到您安装 Qt 的位置(默认/用户/您的用户名/Qt)

Go to the subdirectory 5.7/clang_64/mkspecs directory

进入子目录 5.7/clang_64/mkspecs 目录

Open the file called qdevice.pri with a text editor

使用文本编辑器打开名为 qdevice.pri 的文件

Add line on end file

在结束文件上添加行

!host_build:QMAKE_MAC_SDK = macosx10.12

!host_build:QMAKE_MAC_SDK = macosx10.12

回答by Filip Pokorny

In QT 5.7.0, Xcode 8.0 (8A218a), Mac OSX El Capitan (10.11.6), this issue happened from sudden in already configured environment. 5.7/clang_64/mkspecs/qdevice.prino longer contains QMAKE_MAC_SDKline to modify.

在 QT 5.7.0、Xcode 8.0 (8A218a)、Mac OSX El Capitan (10.11.6) 中,这个问题是在已经配置好的环境中突然发生的。5.7/clang_64/mkspecs/qdevice.pri不再包含QMAKE_MAC_SDK要修改的行。

I suspect some XCode part got silent update and I issue appeared again. This worked:

我怀疑某些 XCode 部分得到了静默更新,我的问题再次出现。这有效:

  1. open XCode and let it reconfigure again (automatic action upon start)
  2. delete .pro.user file from the project
  3. reopen project in QT
  1. 打开 XCode 并让它再次重新配置(启动时自动操作)
  2. 从项目中删除 .pro.user 文件
  3. 在 QT 中重新打开项目

回答by ALoopingIcon

Using QT 5.7.0, Mac OSX Sierra (10.12), XCode 8.0, I got the typical error coming from searching in:

使用 QT 5.7.0、Mac OSX Sierra (10.12)、XCode 8.0,我在搜索时遇到了典型错误:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

instead of:

代替:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk

Adding the line

添加行

!host_build:QMAKE_MAC_SDK = macosx10.12

to the Qt/5.7/clang_64/mkspecs/qdevice.prifile, worked for me.

Qt/5.7/clang_64/mkspecs/qdevice.pri文件,为我工作。

回答by samprat

In my case , I have just opened xcode again. It start installing some components. Once it finished , I open Qt again and everything start working fine.

就我而言,我刚刚再次打开了 xcode。它开始安装一些组件。完成后,我再次打开 Qt,一切都开始正常工作。

回答by Willem van Ketwich

All I had to do was accept the Xcode licence by running: sudo xcodebuild -license accept

我所要做的就是通过运行来接受 Xcode 许可证: sudo xcodebuild -license accept