38

I just updated to the latest version of command line tools in OS X Mavericks and now when compiling my (previously-working) code it throws the following error

> clang: warning: no such sysroot directory:
> '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk'
> In file included from ../QtOpenGL/Main.cpp:1: In file included from
> ../../Qt/5.3/clang_64/lib/QtWidgets.framework/Versions/5/Headers/QApplication:1:
> In file included from
> ../../Qt/5.3/clang_64/lib/QtWidgets.framework/Versions/5/Headers/qapplication.h:45:
> In file included from
> /Users/BB/Qt/5.3/clang_64/lib/QtCore.framework/Headers/qcoreapplication.h:45:
> In file included from
> /Users/BB/Qt/5.3/clang_64/lib/QtCore.framework/Headers/qglobal.h:76:
> /Users/BB/Qt/5.3/clang_64/lib/QtCore.framework/Headers/qsystemdetection.h:196:12:
> fatal error: 'TargetConditionals.h' file not found
> #  include <TargetConditionals.h>
>            ^ 1 error generated. make: *** [Main.o] Error 1 20:29:52: Le processus "/usr/bin/make" s'est terminé avec le code 2. Erreur lors
> de la compilation/déploiement du projet QtOpenGL (kit : Desktop Qt
> 5.3.0 clang 64bit) When executing step "Make"

Does anyone knows that if changing this line

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

from sdk 8 to 9 would work? If so, where in the parameters of Qt5 can I change this?

BRabbit27
  • 5,565
  • 15
  • 81
  • 150

12 Answers12

81

For other people's reference, I solved the issue by editing my platform mkspec file:

/users/nic/Qt/5.3/clang_64/mkspecs/qdevice.pri

change the following line:

!host_build:QMAKE_MAC_SDK = macosx10.8

to this:

!host_build:QMAKE_MAC_SDK = macosx10.9

Be sure to clean your project and run qmake again.

Nic.

  • 7
    Qt 5.4 and xcode 6.1.1 on OSX 10.10.2 (Yosemite) has similar issues, but the Qt/5.4/clang_64/mkspecs/qdevice.pri has no line like the one above. However it is sufficient to add the line `QMAKE_MAC_SDK = macosx10.9` to that file and the problem is solved. – ALoopingIcon Feb 27 '15 at 13:25
  • 7
    I had to do the same when updated to Xcode 7 but with `QMAKE_MAC_SDK = macosx10.11`. – Algebraic Pavel Sep 18 '15 at 13:53
  • I also had to use macosx10.11 after upgrade to El Capitan – Boy Oct 13 '15 at 04:55
  • 3
    One more Apple update, one more Qt change: `QMAKE_MAC_SDK = macosx10.12` for macOS Sierra. – AivanF. Oct 10 '16 at 09:18
  • @ALoopingIcon should be included in the answer. – JDavis Oct 18 '16 at 17:47
  • The file is `qt5/qtbase/mkspecs/qdevice.pri` if you git clone the Qt source where `qt5` is the git root directory. – Carson Ip May 23 '17 at 23:33
  • I had to do the same when upgrading to macOS Sierra with `QMAKE_MAC_SDK = macosx10.12` – djsosofresh Aug 30 '17 at 21:28
25

It is possible to compile the project also by adding the following line to the .pro file

QMAKE_MAC_SDK = macosx10.9
BRabbit27
  • 5,565
  • 15
  • 81
  • 150
  • 5
    This is a much better solution than editing files within the Qt distribution. – gavinb Sep 07 '15 at 09:45
  • 1
    Didn't work for me...? With 10.13 `QMAKE_MAC_SDK = macosx10.13` – Albin Stigo Oct 22 '17 at 13:39
  • @AlbinStigo I haven't used Qt since OS X 10.9 so I cannot assure this still works. Have you tried some of the other suggested solutions? If none of them work, you should try to reach Qt's support or ask another question in SO specifying OS X 10.13 ;) Good luck – BRabbit27 Oct 23 '17 at 09:55
  • @BRabbit27 yes number 3 answer worked (adding this line to another file). Your solution would have been much better. I will probably submit a bug report. – Albin Stigo Oct 24 '17 at 10:46
  • This is a partially correct answer. The problem in recent iterations of macOS is that the system removes old symlinks to the SDK, so you have to fix manually as I explain in https://stackoverflow.com/a/46416172/273934 – Pablo Diaz Dec 15 '17 at 20:05
10

If you compile in other platforms than OS X, an improvement of BRabbit27 solution would be:

macx {
QMAKE_MAC_SDK = macosx10.9
}
asam
  • 349
  • 3
  • 11
10

I just upgraded to XCode 9 and I started getting this problem on macOS Sierra (10.12). The problem is that Xcode moved the default symlink to 10.13. To fix:

cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
sudo ln -s MacOSX.sdk MacOSX10.12.sdk
Pablo Diaz
  • 575
  • 5
  • 15
8

Had the same problem in Qt 5.5, MacOS 10.10.4. I removed .qmake.conf and .qmake.stash from the project directory.

ceed
  • 473
  • 4
  • 15
6

I found out that the file ".qmake.cache" in my project root had a reference to Mac OS 10.8. The solution was to remove the file and build the project from scratch.

Ralf Wirth
  • 61
  • 4
3

I installed Qt 5.9.1 before I installed Xcode 10.13. Since I upgraded the Xcode, error message with following warning started showing up.

:-1: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk' [-Wmissing-sysroot]

I solved the problem changing following line

QMAKE_MAC_SDK = macosx

to

QMAKE_MAC_SDK = macosx10.13

in the following file:

path_where_I_installed_qt/Qt/5.9.1/clang_64/mkspecs/qdevice.pri

I hope it works for you.

mandroid
  • 89
  • 5
3

For me, deleting the output directory contents manually fixed the issue (Qt 5.9, Xcode9, MacOS 10.12.6). Cleaning/Rebuilding did leave some corrupt stuff.

memcpy
  • 31
  • 3
0

For Qt 5.8 and iOS build I added symbolic link to sdk in XCode folders:

cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
ln -s iPhoneOS.sdk iPhoneOS10.0.sdk

cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
ln -s iPhoneSimulator.sdk/ iPhoneSimulator10.2.sdk
Libor B.
  • 419
  • 3
  • 9
0

I am using Qt5.8 on macosx10.13, I solved this problem by editing the file /usr/local/Cellar/qt-legacy-formula/5.8.0_1/mkspecs/qdevice.pri by adding this line:

!host_build:QMAKE_MAC_SDK = macosx10.13
0

I just wanted to comment on this by adding my experience. I recently updated to High Sierra, XCode 9.2, and Qt5.10 and the XCode license message was driving me batty!

In qdevice.pri I changed

QMAKE_MAC_SDK = macosx

to

QMAKE_MAC_SDK = macosz10.13

but that wasn't all that I needed. I had to removed the .qmake.stash and Makefile files from the build directory. I'm not sure removing the Makefile was needed, but I did it anyway. Then I removed the *.pro.user files so that I could force a reconfigure by QtCreator. That forced me or let me select the updated Qt version. Before this I think it was trying to use the older versions of stuff. So, cleaning out all the references to the old stuff in your project and selecting the new is important.

0

Method 1

This kind of error will appear every time you upgrade Xcode

so you can remove cache file in qt before you build or just remove when you get the error

rm {your target build folder}/.qmake.stash

or

rm {your project folder}/.qmake.stash

if you don't know where to find .qmake.stash, try

find ~ -name .qmake.stash

Method 2

Not recommend because you could get build error when you use Xcdoe APP

iphoneOS

cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
sudo ln -s iPhoneOS.sdk iPhoneOS{version}.sdk

iPhoneSimulator

cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/
sudo ln -s iPhoneSimulator.sdk iPhoneSimulator{version}.sdk
Zam
  • 3,768
  • 2
  • 17
  • 14