Click here to Skip to main content
14,334,145 members

Installing Qt on Mac OS X

Rate this:
4.65 (6 votes)
Please Sign up or sign in to vote.
4.65 (6 votes)
18 Oct 2014CPOL
A brief guide on what you need to do to get the Qt Creator to compile and develop Qt Applications on Mac OS X without running into install_name_tool_failed

Introduction

Installing Qt is (usually) an easy task: Download the installer, let it do its duty and done you are. This is certainly applicable if you want your Qt IDE to run on Windows, but when it comes to OS X you are very likely to run into the installer error clang install_name_tool failed. I want to explain what clang is, and why its absence (yes, that error message shall indicate its absence - I was surprised too!) causes the installation to fail. I needed quite a bit of time and a hint from a colleague to find out what was wrong, and since not everyone has the luck of having a colleague who happens to know the answer to most of the problems Qt offers you, I decided to share the solution to the mysterious error clang install_name_tool failed error - Which is as easy as big the surprise is when the error hits you for the first time.

Background - What gets installed?

The setup installs the Qt Creator and the Qt binaries. In addition to that they attempt to configure clang, a C++ compiler, and a failed configuration attempt leads to the already mentioned error message. If that error occurs, you can still run Qt based apps on your Mac and the Qt Creator will still start as nothing happened. The trouble starts when you try to compile your code: It won't, because Qt uses clang via the Xcode Command Line Tools.

Fixing the Issue

After a lot of research and talking to a coworker who happens to be some sort of a Qt Guru I eventually found out the problem: Qt access clang via the Command Line Tools, and these tools are not shipped with every version of Xcode. What surprised me the most is that this is nowhere mentioned if you look at the Qt download page - Not a single word, even though many developers will stumble upon the sane issue. Whatsoever, installing the Command Line Tools is fairly easy if you are already familiar with Xcode, and for those who are new to Xcode it is not that big kind of a deal, either.
Start Xcode - Make sure that you have installed the latest and greatest version, and applied all the updates:
Image 1

Open the preferences. You can find them in the Xcode status bar, under Xcode -> Preferences.

Image 2

Select the tab Downloads -> Components. You can see an item Command Line Tools in the List. Click on Install and Xcode starts downloading and installing the Command Line Tools.

Image 3

After the installation has completed you can install Qt flawlessly with the corresponding installer.

Fixing Xcode is not installed in /Developer/Xcode.app/Contents/Developer

Those who never had Qt installed before most likely encounter the error Xcode is not installed in /Developer/Xcode.app/Contents/Developer when trying to build a project - The solution is easy to find, but added here for completeness. The error has historical roots - Qt still tries to access Xcode in the path /Developer/Xcode.app/Contents/Developer - but Apple has moved the installation to /Applications/Xcode.app/Contents/Developer. I can only guess why they did that, suspecting that the intend was to have Xcode in the location where it belongs: It's and application, so it shall be accessible under /Applications. Enough talking, enter the following command in the Terminal and the error shall be a thing from the past:

sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer 

This behavior is documented as a bug of Qt 5.2 - Details can be found in the Qt Bug 31878 description.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Marco Bertschi
Software Developer
Switzerland Switzerland
I'm a young Software Engineer. Whilst I may accept a 'status quo' as given, it's my responsibility to improve it as soon as the opportunity arises.
Very familiar with the .Net framework since it has been the underlying foundation for most of my professional work so far. I'm that kind of guy who gets stuff done, while I may also improve the way things work whilst I'm at it. Generally can get along well with most people I meet as a professional.
Fervent volunteer firefigter, captain-ranked air force militia spec officer.
Great friend and generally nice to have me around - For a talk, a beer, or a bonfire (I might as well do all of those things combined). Oh, and I really love music - Rock & country that is, mostly.

Comments and Discussions

 
-- There are no messages in this forum --
Tip/Trick
Posted 6 Mar 2014

Tagged as

Stats

54.8K views
5 bookmarked