Qt documentation: Deploying on Mac. Qt offers a deployment tool for Mac: The Mac Deployment Tool. The Mac deployment tool can be found in QTDIR/bin/macdeployqt.It is designed to automate the process of creating a deployable application bundle that contains the Qt.
Prerequisites¶
The prerequisites listed below are required to be able to configure/build/package/test Slicer.
- XCode command line tools must be installed:
- El Capitan is what most developers use.
- CMake 3.12.2 is recommended. Check the minimum required CMake version here
- Large File Storage for git is required. (
brewinstallgit-lvs
) - Qt 5: tested and recommended.
- For building Slicer: download and execute qt-unified-mac-x64-online.dmg, install Qt 5.10, make sure to select
qtscript
andqtwebengine
components. - For packaging and redistributing Slicer: build Qt using qt-easy-build
- For building Slicer: download and execute qt-unified-mac-x64-online.dmg, install Qt 5.10, make sure to select
- Setting
CMAKE_OSX_DEPLOYMENT_TARGET
CMake variable specifies the minimum macOS version a generated installer may target. So it should be equal to or less than the version of SDK you are building on. Note that the SDK version is set usingCMAKE_OSX_SYSROOT
CMake variable automatically initialized during CMake configuration.
Mac OSX 10.9.4 (Mavericks)¶
Qt can be built for either x86 or x8664. 64-bit is used by default. To select a 32-bit build, use the QMAKEAPPLEDEVICEARCHS qmake variable. This is selectable at configure time./configure -platform macx-clang QMAKEAPPLEDEVICEARCHS=i386. Key Features for Mac OS X Development Integrated Development Tools. Qt includes a set of integrated development tools to speed development on the Mac platform. Qt Designer provides a drag and drop visual GUI builder. Qt Linguist provides internationalization and translation features. Qt Assistant is a customizable HTML help file reader providing the complete Qt documentation offline.
- Make sure to install this update: http://support.apple.com/kb/DL1754
- Use CMake 3.12.2 - it is known to be working and is supported (if you want to use CMake already installed on your system, 2.8.12.2 is known to work on Mac OS X 10.9.5)
Mac OSX >= 10.5 (Leopard)¶
- CMake >= 2.8.9
- For Mac Os X >= 10.8 (Mountain Lion) and/or recent XCode >= 4.5.X - CMake >= 2.8.11 is required. See http://www.cmake.org/files/v2.8/cmake-2.8.11-Darwin64-universal.tar.gz
- Git >= 1.7.10
- Svn >= 1.7
- XCode (for the SDK libs)
- After installing XCode, install XCode command line developer tools:
- XQuartz - For Mac Os X >= 10.8 (Mountain Lion) install XQuartz (http://xquartz.macosforge.org) to get X11 (no longer a default in OS X).
- Qt 4 >= 4.8.5. We recommend you install the following two packages:
- Download and install [http://download.qt-project.org/official_releases/qt/4.8/4.8.6/qt-opensource-mac-4.8.6-1.dmg qt-opensource-mac-4.8.6-1.dmg]
- Download and install [http://download.qt-project.org/official_releases/qt/4.8/4.8.6/qt-opensource-mac-4.8.6-1-debug-libs.dmg qt-opensource-mac-4.8.6-1-debug-libs.dmg]
Mac OSX 10.11 (El Capitan)¶
XCode up to version 7 is known to work for Slicer compilation. XCode 8 breaks things on several levels for now.Remember to install XCode command line tools (see above) if a reinstall for XCode is needed.
The standard Qt4 installers fail on this version and the 4.8.6 source code won’t build. But as described on the slicer-devel mailing list it is possible to install the homebrew version of qt4 which patches it to work on El Capitan (see below).
- Install the
OS
,Xcode
, andXQuartz
(see MacOSX 10.10 above) - Install
Qt4
by running the following two commands:
- TCL does not build correctly on El Capitan as of 2015-12-03, so when building Slicer turn
Slicer_USE_PYTHONQT_WITH_TCL
off.
Mac OSX 10.12 (Sierra)¶
Similar to 10.11 (El Capitan), there are new issues with Qt4 (caused by Phonon).The GitHub user Cartr offered a patch to the brew team, and even though it was not integrated (the homebrew team decided to stop patching their recipe to encourage people to use Qt5), he turned his formula into a tap that can be installed (see below).
Follow instructions for 10.11 (Installing Xcode, XQuartz, run without TCL) but install Qt4 like shown below instead:
Confirmed with Xcode:
- Version 8.1 (8B62) and cmake version 3.4.20151021-g8fbc8e
- Version 8.3.3 and cmake 3.5.2
Mac OSX 10.14 (Mojave)¶
(Associated discussion topic is https://discourse.slicer.org/t/building-on-mac-10-14-mojave/4554/21)
- Install Qt 5.11.2 using Qt Online Installer for macOS
- Install XCode:
- Build qt from homebrew
- Explicitly set the SDK when running make
Note if you have build errors in dcmtk related to iconv symbols, you may need to uninstall the icu4c and dcmtk homebrew packages during the build process. See here and here.
Checkout Slicer source files¶
Notes:
- While it is not enforced, we strongly recommend you to avoid the use of spaces for both the
sourcedirectory
and thebuilddirectory
. - Due to maximum path length limitations during build the build process, source and build folders must be located in a folder with very short total path length. This is expecially critical on Windows and MacOS. For example,
/sq5
has been confirmed to work on MacOS.
Check out the code using
git
:- Clone the github repository
The `Slicer``` directory is automatically created after cloning Slicer.
- Setup the development environment:
Configure and generate Slicer solution files¶
- Configure using the following commands. By default
CMAKE_BUILD_TYPE
is set toDebug
(replace/path/to/QtSDK
with the real path on your machine where QtSDK is located):
- If
usingQtfromthesystem
, do not forget to add the following CMake variable to your configuration command line:-DSlicer_USE_SYSTEM_QT:BOOL=ON
- Remarks:
- Instead of
cmake
, you can useccmake
orcmake-gui
to visually inspect and edit configure options. - Using top-level directory name like
Slicer-SuperBuild-Release
orSlicer-SuperBuild-Debug
is recommended. - Additional configuration options to customize the application are described here.
- Instead of
- On Mac OS X 10.9 (Mavericks) / 10.10 (Yosemite) / 10.11 (El Capitan), also set the following variables (see discussion):
Slicer_USE_PYTHONQT_WITH_TCL
->OFF
CMAKE_OSX_DEPLOYMENT_TARGET
->10.9
or10.10
or10.11
General information¶
Two projects are generated by either
cmake
, ccmake
or cmake-gui
. One of them is in the top-level bin directory Slicer-SuperBuild
and the other one is in the subdirectory Slicer-build
:Slicer-SuperBuild
manages all the external dependencies of Slicer (VTK, ITK, Python, …). To build Slicer for the first time, run make (or build the solution file in Visual Studio) inSlicer-SuperBuild
, which will update and build the external libraries and if successful will then build the subproject Slicer-build.Slicer-SuperBuild/Slicer-build
is the “traditional” build directory of Slicer. After local changes in Slicer (or after an svn update on the source directory of Slicer), only running make (or building the solution file in Visual Studio) inSlicer-SuperBuild/Slicer-build
is necessary (the external libraries are considered built and up to date).
Warning: An significant amount of disk space is required to compile Slicer in Debug mode (>10GB)
Warning: Some firewalls will block the git protocol. See more information and solution here.
Build Slicer¶
After configuration, start the build process in the
Slicer-SuperBuild
directory- Start a terminal and type the following (you can replace 4 by the number of processor cores in the computer):
In case of file download hash mismatch error, you need to acquire the latest wget, and build cmake with OpenSSL turned on. For more information, see here and here.
When using the -j option, the build will continue past the source of the first error. If the build fails and you don’t see what failed, rebuild without the -j option. Or, to speed up this process build first with the -j and -k options and then run plain make. The -k option will make the build keep going so that any code that can be compiled independent of the error will be completed and the second make will reach the error condition more efficiently.
Run Slicer¶
Start a terminal and type the following:
Test Slicer¶
After building, run the tests in the
Slicer-SuperBuild/Slicer-build
directory.Start a terminal and type the following (you can replace 4 by the number of processor cores in the computer):
Package Slicer¶
Start a terminal and type the following:
Common errors¶
See list of issues common to all operating systems on Common errors page.
CMake complains during configuration¶
CMake may not directly show what’s wrong; try to look for log files of the form BUILD/CMakeFiles/*.log (where BUILD is your build directory) to glean further information.
error: ‘class QList’ has no member named ‘reserve’¶
You have multiple Qt versions installed on your machine. Try removing the Qt version installed on the system.
libarchive.so: undefined reference to `SHA256_Update’¶
Solution:
Details:
- http://na-mic.org/Mantis/view.php?id=1616
- http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=18923
- http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=18969
ld: framework not found QtWebKit¶
See Slicer issue 2860.
Workaround:
- See http://public.kitware.com/Bug/view.php?id=13765#c31824
Solution:
- Use a recent CMake. It includes patch cc676c3a. Note also that the coming version of CMake 2.8.11 will work as expected.
On MacOSX 10.8, CMake hangs forever¶
Issue: http://www.na-mic.org/Bug/view.php?id=2957
Solution: Use CMake build >= 2.8.10.20130220-g53b279. See http://www.cmake.org/files/dev/cmake-2.8.10.20130220-g53b279-Darwin-universal.tar.gz
Details:
CMake folks (Thanks Brad King :)) fixed an issue that was preventing the most recent nightly from being used to successfully compile Slicer. The fix has been tested and is known to work. Tomorrow nightly build of CMake and by extension the coming release of CMake 2.8.11 will work.
If you are curious about the details, check the commit message: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1df09e57
The associated CMake test have also been updated: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bff3d9ce
On MacOSX 10.8/10.9 with XQuartz, ‘X11/Xlib.h’ file not found¶
Issue: http://www.na-mic.org/Bug/view.php?id=3405
Workaround: Build with -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF
Tcl is required only for EMSegment module.
Details: See http://www.na-mic.org/Bug/view.php?id=3405
‘QSslSocket’ : is not a class or namespace name¶
This error message occurs if Slicer is configured to use SSL but Qt is built without SSL support.
Either set Slicer_USE_PYTHONQT_WITH_OPENSSL to OFF when configuring Slicer build in CMake, or build Qt with SSL support.
error: Missing Qt module QTWEBKIT¶
Solution:
Details: http://slicer-devel.65872.n3.nabble.com/Re-slicer-devel-Digest-Vol-143-Issue-39-td4037122.html
![For For](/uploads/1/1/9/3/119367785/618782939.png)
error when starting Slicer: NameError: name ‘getSlicerRCFileName’ is not defined¶
Solution and details here
macOS: error while configuring PCRE: “cannot run C compiled program”¶
If the XCode command line tools are not properly set up on OS X, PCRE could fail to build in the Superbuild process with the errors like below:
To install XCode command line tools, use the following command from the terminal:
macOS: dyld: malformed mach-o: load commands size (…) > 32768¶
Path of source or build folder is too long. For example building Slicer in /User/somebody/projects/something/dev/slicer/slicer-qt5-rel may fail with malformed mach-o error, while it succeeds in /sq5 folder. To resolve this error, move source and binary files into a folder with shorter full path and restart the build from scratch (the build tree is not relocatable).
Qt on Mac OS X
Qt is a comprehensive application and UI framework for developing Mac applications that can also be deployed across many other desktop and embedded operating systems without rewriting the source code. Use the code from one single code-base and rebuild for all supported Windows versions and other platforms.
Getting Started on Mac
- Supported Mac OS X platforms - Qt supports a wide range of Mac platform variants.
- Qt for Mac OS X Requirements - Software required to run Qt on Mac OS X.
- Installing Qt for X11 Platforms - Build Qt for Mac OS X development.
Key Features for Mac OS X Development
![Build Build](/uploads/1/1/9/3/119367785/766638194.png)
Integrated Development Tools
Qt includes a set of integrated development tools to speed development on the Mac platform.
- Qt Designer provides a drag and drop visual GUI builder.
- Qt Linguist provides internationalization and translation features.
- Qt Assistant is a customizable HTML help file reader providing the complete Qt documentation offline.
Cross-Platform Development using Qt Creator
Qt Creator is a complete Cross-platform IDE included in the Qt SDK. The IDE allows programmers to create, build, debug and run Qt applications accross all supported platforms.
Rich Class Library
Build Qt For Mac Os 10.10
The Qt class library includes all the functionality needed to build advanced GUI applications.
Install Mac Os X
- Complete set of customizable UI controls/widgets
- 3D graphics support with OpenGL integration
- Powerful multi-threading features
- 2D graphics canvas capable of handling millions of items
- Integrated Phonon multimedia framework
- WebKit integration
- Networking, XML and database functionality
- ECMA standard scripting engine
Supports Intel Hardware and Universal Binaries
Qt is written without making assumptions about the number representation, endianness or architecture of the underlying processor. To support Intel hardware on the Apple platforms, Qt customers simply need to recompile their apps.
Build Qt For Mac Os 10.13
Additional Cross-Platform and Platform-Specific Development information.
Qt Build Mac Os X
Note: Qt also provides support for 64-bit applications on top of Cocoa APIs.
Qt For Mac
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.