Free icon for mac. OS X El Capitan. OS X Mountain Lion. OS X Yosemite. OS X Mavericks.
- Build Qt Macos
- Qt Creator Mac Download
- Build Standalone Qt Application For Mac
- Build Qt For Mac Osx
- Build Qt For Mac Catalina
This article applies to macOS only.
See also: Multiplatform Programming Guide
My Qt app has today been accepted and is available on the App Store. So the answer is yes, Apple will accept Qt based applications. Here's some information about my application. It written in C and uses Qt v4.7.2 under the LGPL license. Step 1: Build and prepare for release. Once you run the build process with your tool of choice, you should have a.app bundle.Run macdeployqt to copy the Qt framework files. You need to run codesign to sign the app binary.You need to pass -options=runtime.This is what it means to 'Enable a hardened runtime' which doesn't involve anything at the compilation step. I'm trying to build a static, universal Qt from source on Mac OS X 10.6 using the following command: sh configure -static -opensource -universal The problem, I have been told, is that PPC is not supported on 10.6 so I am getting many errors and the build eventually fails. So I need to build for a different target version of OS X - 10.4 or 10.5. These are building instructions for building Qt for Android on Linux or Mac OS X. For cross-compiling on Windows, this is currently possible under cmd.exe. For general information about Qt 5 for Android, please visit the wiki for that.
This article applies to Qt widgetset only.
See also: Multiplatform Programming Guide
│English (en) │ 日本語 (ja) │
- 2Quick Install and Use Guide
- 3Outdated Build Guide
- 3.6Creating a Qt based Lazarus
Introduction
There are two main path you can follow to start deploying your first Qt Application for Mac:
- Install compiled Interface Binary Bindings and Qt Framework Library
- Build yourself Interface Binary Bindings and Qt Framework Library (hard and may take many hours)
Quick Install and Use Guide
Fastest way to get you ready to develop applications with Qt Framework (+ LCL Widgetset)
Qt4 Framework Library
First you need to download the Cocoa Mac binary package of Qt4 Framework Library from Nokia Qt download section or from a Trolltech mirror. The file you need is named something like qt-mac-opensource-4.7.4.dmg or with greater version.
- Now Mount the disk image and install the package that you find inside.
Qt4 Interface Binary Bindings
Next you need to download the Interface Binary Bindings from Jan.Van.hijfte site, search for Mac: Libray Binary Intel, the file you download is named something like mac_bin-qt4pas-V2.4_Qt4.5.3.zip (don't worry about version in file name, it's indicating the lowest version required by Binaries).
- After you click on the downloaded file it will be automatically unpacked and you will see another zip inside, unzip it too and install the package you find inside.
- (Optional) Rename qt4.pas in qt45.pas and copy it inside /Developer/lazarus/lcl/interfaces/qt
Build Lazarus IDE on Qt
Lazarus 1.2/1.3You must rebuild libQt4Pas library according to your needs (32/64bit).Build with make (from terminal):
- 32bit (Carbon): make bigide LCL_PLATFORM=qt
- 64bit (Cocoa): make bigide OS_TARGET=darwin CPU_PLATFORM=x86_64 LCL_PLATFORM=qt
Build from Lazarus IDE:
- 32bit just set qt widgetset in ide build config dialog and rebuild.
- 64bit set qt widgetset and add -Px86_64 -Tdarwin in ide build config dialog.IMPORTANT NOTE: you must build IDE with make first (from terminal), and then you can rebuild from IDE because of bug (dunno where it is) which causes linking of lazarus against 32bit objects.
Build Lazarus with qt-cocoa (qt binary distribution from nokia >= 4.7.4)
Qt binary distribution (>=4.7.4) is 64bit (cocoa only), so we need 64bit Qt4Pas and 64bit 2.6.0 compiler
- Download and install fpc-2.6.0 (with 2.4.4 64bit you can compile lazarus etc but it will crash imediatelly).I've used 'svn co http://svn.freepascal.org/svn/fpc/tags/release_2_6_0 fpc260' , then 'fpcmake -Tall' , 'make all', 'sudo make install', 'sudo make CPU_TARGET=x86_64 make install' (of course you need fpc-2.4.4 to build 2.6.0, you can download dmgs from lazarus daily snapshots.
- Download qt-4.7.4 from nokia site (DO NOT DOWNLOAD 4.8.0 SINCE IT'S WRONGLY PACKAGED atm - won't work (missing symbols in QWebKit) https://bugreports.qt.nokia.com/browse/QTBUG-23157 )
- Install qt
- Download qt bindings source (Qt4Pas).
- Open Qt4Pas.pro and comment CXXFLAGS += -mstackrealign (since it will be error with 64bit build on mac).
- Build and install bindings as in readme.
- dload lazarus trunk.
Build from terminal (short way)
- make bigide CPU_TARGET=x86_64 LCL_PLATFORM=qt OPT='-k'-framework' -k'ApplicationServices' (don't forget to change default compiler in Tools->Options->Compiler path)
Build carbon from terminal, then ide from ide
- build it for carbon (32bit), startlazarus, go to Tools->Options, change cpu from /usr/local/bin/fpc to /usr/local/bin/ppcx64 in Compiler path (also fix source path to 2.6.0 if it isn't already fixed).
- Tools->Configure Build Lazarus-> choose LCL widget type qt, in options write -k-framework -kApplicationServices (yes, without any quotes)
- Build lazarus
Spotted problems
- Qt-cocoa have problems with mouseGrabber (possible it's fixed in 4.8.0)
- Cannot build pure cocoa widget set ATSUXXXX symbols are missing (probably need to pass more frameworks to linker)
Build environment
- 10.6.8 (Snow Leopard)
- XCode 3.(Don't know - but it's free one)
Build your first Qt Application
- Note: Latest Lazarus IDE creates Application Bundles by himself when you create a new project, so you don't need to worry about this (while you leave the Create Application Bundle check box inside Project -> Project Options -> Application tab to it's default enabled state.
- Create a new project or use the default one that Lazarus IDE creates on first launch.
- Add some buttons and edit boxes to your form.
- Inside Project -> Project Options -> Compile Options -> Build modes click on empty macro line and choose LCLWidgetType, in relative macro value choose qt and click Ok.
- Now click green Run arrow and congratulate with yourself for building your first Qt Application.
Outdated Build Guide
Shebuka 17:03, 8 September 2011 (CEST) At this time, this part of guide can't be followed, because all shell script mentioned here to build Interface and Libraries are not present in Mac library sources.
Sections 2, 3, and 4 only need to be done if you are creating the Interface library, and Interface framework yourself. If you have installed the interface framework using Mac Library Binary (intel), you can start with section 5 and begin compiling the demo programs.
Notes on terminology:
These instructions generally use the term 'Qt libraries' to describe the QtCore and QtGui libraries that are created in section 2. The term 'interface library' is used to describe the Qt4Intf library created in section 3 that interfaces between Free Pascal and the Qt libraries. The 'interface framework' is an macOS-specific folder created in section 4 that contains both the Qt libraries and interface library and can be linked against when compiling with Free Pascal.
Bootable usb for mac os x lion. If you're not familiar with macOS terms such as 'framework' and 'app bundle', refer to Apple's extensive online documentation.
Important! To run any of the scripts mentioned in sections 3-6, you may need to change its permission so that macOS will allow it to be executed:
Install the Qt Library Frameworks
- Download and install Qt4 from Trolltech/Nokia: [http:/ftp://ftp.trolltech.com/qt/source/]. The file will be named something like qt-mac-opensource-4.5.X.dmg.
- Several Qt frameworks will be installed in /Library/Frameworks. QtCore.framework and QtGui.framework are used.
Creating the Qt interface library
A script file for doing this is included with Mac library source. The downloaded file will be named like mac_qt4pas-V1.XX_Qt4.4.X.zip Download and double-click this file to create folder qt4pas-V1.XX_Qt4.4.X.zip. Move this folder to your home folder and change to it (cd). Run the script as follows:
This script will use the GCC g++ (installation of macOS DevSDK (Xcode) is required) compiler to compile qtpas.cpp and create Qt4Intf, the Qt interface library. If the script can't find the Qt4 library frameworks, it will output an error message. The script does not check the exact Qt version, use the appropriate Qt (Qt4.3.X cannot be mixed with Qt 4.4.X)
Creating the Qt interface framework
A script file for doing this is included with mac_qt4pas-1.xx.zip. Run the script as follows:
This creates the Qt4Intf.framework folder under /Library/Frameworks. Note that sudo is required because of the need of write access in the /Library/Frameworks folder.
If the script can't find the Qt4Intf library it needs, it will output an error message. you need to compile it first (see step above)
Compiling the non-Lazarus demo programs with Free Pascal
The Pascal source for several demo programs is included in file mac_demos-1.xx.zip. Download and double-click this file to create folder demos-1.xx. Move this folder to your home folder (/Users/login) and change to it (cd).
To compile one of the demo programs:
Serial number for adobe acrobat pro mac. This will compile the demo program with Free Pascal, creating an executable file with the same name.
Tip: The compile script uses the compiler option -Fu.(find units in parent directory) to only need a single copy for all demoes of the rather large Qt4.pas file.
Note that Lazarus is not required to compile these demo programs.
Creating a demo program application bundle
To create a double-clickable application on macOS, you need to create an app bundle. An app bundle is a folder with an .app extension in its name that looks like a file to the user. A script file is included for doing this:
This creates the somedemo.app folder, as well as several folders and files inside it.
Note that this script does not copy the executable file into the app bundle the way you normally would when you're ready to distribute an app bundle. Instead, it creates a symbolic link inside the folder that points to the executable in the somedemo folder. This approach allows you to edit and compile a program as many times as necessary without needing to copy the executable file into the app bundle folder after each compile in order to run it.
In Finder, double-click the somedemo application (not the executable file) to launch it. You can also drag and drop the somedemo application onto the dock and launch it from there.
Creating a Qt based Lazarus
Starting purely from source
Note: The X11 package does not have to be installed at all.
- Checkout svn source
in a terminal do
- Compile lazarus using installed Qt4Intf framework
- adapt USE_QT_45 to the used Qt version
- since svn >= 21913, Qt 4.5 is default, no need to define any USE_XX_YY when using Qt 4.5
- run lazarus :-)
Starting from a Gtk based Lazarus
Currently Lazarus is only available for the X11-based GTK widgetset. The compiled LCL units included with Lazarus are only available for the GTK widgetset as well. The LCL units are also installed read-only, so the easiest way of compiling them for the Qt widgetset is simply to copy the LCL source to your home folder and rebuild it there. Here are the steps:
- Copy the 'lazarus' folder from /usr/local/share to your home folder (/Users/login).
Tip: How do you get to the Lazarus folder? In Finder, choose Go | Go to Folder and enter /usr, then navigate to /usr/local/share.
Tip: You can also use Subversion (SVN) to download the Lazarus source to a folder in your home folder (or someplace where you have write access to it).
Tip: For the purposes of these examples, you really only need to copy the Lazarus 'lcl' folder, but you'll need to ignore the warnings that Lazarus gives you later on.
- Make sure the Qt widgetset is using an up-to-date version of qt4.pas. Compare the version of qt4.pas file used in section 5 above with /Users/login/Lazarus/lcl/interfaces/qt/qt4.pas. The version should be indicated in a comment at the top of qt4.pas. If necessary, install a more recent version of Lazarus.
- Start Lazarus by opening an X11 window and entering:
- In Lazarus, choose Tools -> Options -> Environment. On the Files tab, change the Lazarus directory from /usr/local/share/lazarus to
If you only copied the 'lcl' folder, you'll get a warning when you click OK. Click Ignore to ignore the warning.
- In Lazarus, choose Tools | Configure 'Build Lazarus'. Set Build LCL to 'Build'; set all others to 'None'. Also click 'qt' under LCL interface.
- Click the Build button.
- When Free Pascal is done compiling the LCL, check that you have newly created .ppu and .o files in /Users/login/Lazarus/lcl/units/powerpc-darwin/qt.
- Choose Tools | Configure, restore the LCL interface setting to 'gtk', then click 'Save settings'.
Creating an LCL app that uses the Qt widgetset
- Create a new project in Lazarus. When you started Lazarus, it created a new project -- you can use this.
- In Lazarus, choose Project | Compiler Options. On the Paths tab, select 'qt' under LCL Widget Type.
- On the Linking tab, select Pass Options To The Linker and enter
and click OK.
- Add one or more controls to your project's main form. Since the Qt widgetset is a work in progress, consult Roadmap#Widgetset_dependent_components to see which controls are working.
In the meantime qt widgetset becomes more mature, so you can see Lazarus Qt IDE under macOS
- Save the project to a folder in your home folder (/Users/login).
- In Lazarus, choose Run | Build to compile the project.
Tip: You can also compile your project from a script:
You can change most of the switches as needed, but be sure to leave the -k switches alone. If necessary, change the first line to the path to the LCL units you created in the previous section.
- Before running the app, make sure you've created an app bundle for it. You can copy the create_app_mac.sh script from section 6 to your project's folder and run it to create an app bundle for your compiled project.
- To run the app, double-click the application (not the executable file) in Finder or drag it to the dock and launch it from there.
- Before writing mac apps read macOS Human Interface guidelines.
Distributing an app that uses the Qt Interface Framework
- The Lazarus IDE creates a symbolic link inside the application bundle to the actual executable file. To copy the executable file into the application bundle in order to distribute it along with the application bundle, do this:
You should substitute the name of your application for 'MyApp' above.
- Consult Deploying Your Application#An Application Bundle for help with creating a distributable disk image file (.dmg extension) from your application bundle folder. Ignore the discussion of X11 and GTK since your app does not require them!
- Your application will depend on the Qt4 Framework Library and on the Qt4 Interface Binary Bindings. You can put these files inside your application bundle like you do with .dylib following macOS Programming Tips#Using a library in a Mac application.
- Read Deploying an Application on macOS about adding the Qt framework to your application bundle. Very handy for that purpose is the tool macdeployqt.
Uninstalling the Qt4 Interface and Qt4 Framework
- If you need to remove the Qt4 Interface from your computer, simply drag the Qt4Pas.framework folder from /Library/Frameworks to the trash. Finder will prompt you for your password before allowing this.
- If you need to remove the Qt4 Framework from your computer, simply drag the Qt3Support.framework and all QtXxxx.framework folders (like QtCore.framework, QtGui.framework, QtWebKit.framework ecc.) from /Library/Frameworks to the trash. Finder will prompt you for your password before allowing this.
- (Optional) You can also drag Qt4 Free Pascal Interface.pkg (if present) from /Library/Receipts to the trash.
Qt for Mac OS X has some requirements that are given in more detail in the Qt for Mac OS X Requirements document.
The following instructions describe how to install Qt from the source package.
For the binary package, simply double-click on the Qt.mpkg and follow the instructions to install Qt. You can later run the uninstall-qt.py
script to uninstall the binary package. The script is located in /Developer/Tools and must be run as root.
Note: Do not run the iPhone simulator while installing Qt. The iPhone simulator conflicts with the package installer.
Build Qt Macos
Step 1: Install the License File (commercial editions only)
If you have the commercial edition of Qt, install your license file as $HOME/.qt-license
.
For the open source version you do not need a license file.
Unpack the archive if you have not done so already. For example, if you have the qt-everywhere-opensource-src-%VERSION%.tar.gz
package, type the following commands at a command line prompt:
My Qt app has today been accepted and is available on the App Store. So the answer is yes, Apple will accept Qt based applications. Here's some information about my application. It written in C and uses Qt v4.7.2 under the LGPL license. Step 1: Build and prepare for release. Once you run the build process with your tool of choice, you should have a.app bundle.Run macdeployqt to copy the Qt framework files. You need to run codesign to sign the app binary.You need to pass -options=runtime.This is what it means to 'Enable a hardened runtime' which doesn't involve anything at the compilation step. I'm trying to build a static, universal Qt from source on Mac OS X 10.6 using the following command: sh configure -static -opensource -universal The problem, I have been told, is that PPC is not supported on 10.6 so I am getting many errors and the build eventually fails. So I need to build for a different target version of OS X - 10.4 or 10.5. These are building instructions for building Qt for Android on Linux or Mac OS X. For cross-compiling on Windows, this is currently possible under cmd.exe. For general information about Qt 5 for Android, please visit the wiki for that.
This article applies to Qt widgetset only.
See also: Multiplatform Programming Guide
│English (en) │ 日本語 (ja) │
- 2Quick Install and Use Guide
- 3Outdated Build Guide
- 3.6Creating a Qt based Lazarus
Introduction
There are two main path you can follow to start deploying your first Qt Application for Mac:
- Install compiled Interface Binary Bindings and Qt Framework Library
- Build yourself Interface Binary Bindings and Qt Framework Library (hard and may take many hours)
Quick Install and Use Guide
Fastest way to get you ready to develop applications with Qt Framework (+ LCL Widgetset)
Qt4 Framework Library
First you need to download the Cocoa Mac binary package of Qt4 Framework Library from Nokia Qt download section or from a Trolltech mirror. The file you need is named something like qt-mac-opensource-4.7.4.dmg or with greater version.
- Now Mount the disk image and install the package that you find inside.
Qt4 Interface Binary Bindings
Next you need to download the Interface Binary Bindings from Jan.Van.hijfte site, search for Mac: Libray Binary Intel, the file you download is named something like mac_bin-qt4pas-V2.4_Qt4.5.3.zip (don't worry about version in file name, it's indicating the lowest version required by Binaries).
- After you click on the downloaded file it will be automatically unpacked and you will see another zip inside, unzip it too and install the package you find inside.
- (Optional) Rename qt4.pas in qt45.pas and copy it inside /Developer/lazarus/lcl/interfaces/qt
Build Lazarus IDE on Qt
Lazarus 1.2/1.3You must rebuild libQt4Pas library according to your needs (32/64bit).Build with make (from terminal):
- 32bit (Carbon): make bigide LCL_PLATFORM=qt
- 64bit (Cocoa): make bigide OS_TARGET=darwin CPU_PLATFORM=x86_64 LCL_PLATFORM=qt
Build from Lazarus IDE:
- 32bit just set qt widgetset in ide build config dialog and rebuild.
- 64bit set qt widgetset and add -Px86_64 -Tdarwin in ide build config dialog.IMPORTANT NOTE: you must build IDE with make first (from terminal), and then you can rebuild from IDE because of bug (dunno where it is) which causes linking of lazarus against 32bit objects.
Build Lazarus with qt-cocoa (qt binary distribution from nokia >= 4.7.4)
Qt binary distribution (>=4.7.4) is 64bit (cocoa only), so we need 64bit Qt4Pas and 64bit 2.6.0 compiler
- Download and install fpc-2.6.0 (with 2.4.4 64bit you can compile lazarus etc but it will crash imediatelly).I've used 'svn co http://svn.freepascal.org/svn/fpc/tags/release_2_6_0 fpc260' , then 'fpcmake -Tall' , 'make all', 'sudo make install', 'sudo make CPU_TARGET=x86_64 make install' (of course you need fpc-2.4.4 to build 2.6.0, you can download dmgs from lazarus daily snapshots.
- Download qt-4.7.4 from nokia site (DO NOT DOWNLOAD 4.8.0 SINCE IT'S WRONGLY PACKAGED atm - won't work (missing symbols in QWebKit) https://bugreports.qt.nokia.com/browse/QTBUG-23157 )
- Install qt
- Download qt bindings source (Qt4Pas).
- Open Qt4Pas.pro and comment CXXFLAGS += -mstackrealign (since it will be error with 64bit build on mac).
- Build and install bindings as in readme.
- dload lazarus trunk.
Build from terminal (short way)
- make bigide CPU_TARGET=x86_64 LCL_PLATFORM=qt OPT='-k'-framework' -k'ApplicationServices' (don't forget to change default compiler in Tools->Options->Compiler path)
Build carbon from terminal, then ide from ide
- build it for carbon (32bit), startlazarus, go to Tools->Options, change cpu from /usr/local/bin/fpc to /usr/local/bin/ppcx64 in Compiler path (also fix source path to 2.6.0 if it isn't already fixed).
- Tools->Configure Build Lazarus-> choose LCL widget type qt, in options write -k-framework -kApplicationServices (yes, without any quotes)
- Build lazarus
Spotted problems
- Qt-cocoa have problems with mouseGrabber (possible it's fixed in 4.8.0)
- Cannot build pure cocoa widget set ATSUXXXX symbols are missing (probably need to pass more frameworks to linker)
Build environment
- 10.6.8 (Snow Leopard)
- XCode 3.(Don't know - but it's free one)
Build your first Qt Application
- Note: Latest Lazarus IDE creates Application Bundles by himself when you create a new project, so you don't need to worry about this (while you leave the Create Application Bundle check box inside Project -> Project Options -> Application tab to it's default enabled state.
- Create a new project or use the default one that Lazarus IDE creates on first launch.
- Add some buttons and edit boxes to your form.
- Inside Project -> Project Options -> Compile Options -> Build modes click on empty macro line and choose LCLWidgetType, in relative macro value choose qt and click Ok.
- Now click green Run arrow and congratulate with yourself for building your first Qt Application.
Outdated Build Guide
Shebuka 17:03, 8 September 2011 (CEST) At this time, this part of guide can't be followed, because all shell script mentioned here to build Interface and Libraries are not present in Mac library sources.
Sections 2, 3, and 4 only need to be done if you are creating the Interface library, and Interface framework yourself. If you have installed the interface framework using Mac Library Binary (intel), you can start with section 5 and begin compiling the demo programs.
Notes on terminology:
These instructions generally use the term 'Qt libraries' to describe the QtCore and QtGui libraries that are created in section 2. The term 'interface library' is used to describe the Qt4Intf library created in section 3 that interfaces between Free Pascal and the Qt libraries. The 'interface framework' is an macOS-specific folder created in section 4 that contains both the Qt libraries and interface library and can be linked against when compiling with Free Pascal.
Bootable usb for mac os x lion. If you're not familiar with macOS terms such as 'framework' and 'app bundle', refer to Apple's extensive online documentation.
Important! To run any of the scripts mentioned in sections 3-6, you may need to change its permission so that macOS will allow it to be executed:
Install the Qt Library Frameworks
- Download and install Qt4 from Trolltech/Nokia: [http:/ftp://ftp.trolltech.com/qt/source/]. The file will be named something like qt-mac-opensource-4.5.X.dmg.
- Several Qt frameworks will be installed in /Library/Frameworks. QtCore.framework and QtGui.framework are used.
Creating the Qt interface library
A script file for doing this is included with Mac library source. The downloaded file will be named like mac_qt4pas-V1.XX_Qt4.4.X.zip Download and double-click this file to create folder qt4pas-V1.XX_Qt4.4.X.zip. Move this folder to your home folder and change to it (cd). Run the script as follows:
This script will use the GCC g++ (installation of macOS DevSDK (Xcode) is required) compiler to compile qtpas.cpp and create Qt4Intf, the Qt interface library. If the script can't find the Qt4 library frameworks, it will output an error message. The script does not check the exact Qt version, use the appropriate Qt (Qt4.3.X cannot be mixed with Qt 4.4.X)
Creating the Qt interface framework
A script file for doing this is included with mac_qt4pas-1.xx.zip. Run the script as follows:
This creates the Qt4Intf.framework folder under /Library/Frameworks. Note that sudo is required because of the need of write access in the /Library/Frameworks folder.
If the script can't find the Qt4Intf library it needs, it will output an error message. you need to compile it first (see step above)
Compiling the non-Lazarus demo programs with Free Pascal
The Pascal source for several demo programs is included in file mac_demos-1.xx.zip. Download and double-click this file to create folder demos-1.xx. Move this folder to your home folder (/Users/login) and change to it (cd).
To compile one of the demo programs:
Serial number for adobe acrobat pro mac. This will compile the demo program with Free Pascal, creating an executable file with the same name.
Tip: The compile script uses the compiler option -Fu.(find units in parent directory) to only need a single copy for all demoes of the rather large Qt4.pas file.
Note that Lazarus is not required to compile these demo programs.
Creating a demo program application bundle
To create a double-clickable application on macOS, you need to create an app bundle. An app bundle is a folder with an .app extension in its name that looks like a file to the user. A script file is included for doing this:
This creates the somedemo.app folder, as well as several folders and files inside it.
Note that this script does not copy the executable file into the app bundle the way you normally would when you're ready to distribute an app bundle. Instead, it creates a symbolic link inside the folder that points to the executable in the somedemo folder. This approach allows you to edit and compile a program as many times as necessary without needing to copy the executable file into the app bundle folder after each compile in order to run it.
In Finder, double-click the somedemo application (not the executable file) to launch it. You can also drag and drop the somedemo application onto the dock and launch it from there.
Creating a Qt based Lazarus
Starting purely from source
Note: The X11 package does not have to be installed at all.
- Checkout svn source
in a terminal do
- Compile lazarus using installed Qt4Intf framework
- adapt USE_QT_45 to the used Qt version
- since svn >= 21913, Qt 4.5 is default, no need to define any USE_XX_YY when using Qt 4.5
- run lazarus :-)
Starting from a Gtk based Lazarus
Currently Lazarus is only available for the X11-based GTK widgetset. The compiled LCL units included with Lazarus are only available for the GTK widgetset as well. The LCL units are also installed read-only, so the easiest way of compiling them for the Qt widgetset is simply to copy the LCL source to your home folder and rebuild it there. Here are the steps:
- Copy the 'lazarus' folder from /usr/local/share to your home folder (/Users/login).
Tip: How do you get to the Lazarus folder? In Finder, choose Go | Go to Folder and enter /usr, then navigate to /usr/local/share.
Tip: You can also use Subversion (SVN) to download the Lazarus source to a folder in your home folder (or someplace where you have write access to it).
Tip: For the purposes of these examples, you really only need to copy the Lazarus 'lcl' folder, but you'll need to ignore the warnings that Lazarus gives you later on.
- Make sure the Qt widgetset is using an up-to-date version of qt4.pas. Compare the version of qt4.pas file used in section 5 above with /Users/login/Lazarus/lcl/interfaces/qt/qt4.pas. The version should be indicated in a comment at the top of qt4.pas. If necessary, install a more recent version of Lazarus.
- Start Lazarus by opening an X11 window and entering:
- In Lazarus, choose Tools -> Options -> Environment. On the Files tab, change the Lazarus directory from /usr/local/share/lazarus to
If you only copied the 'lcl' folder, you'll get a warning when you click OK. Click Ignore to ignore the warning.
- In Lazarus, choose Tools | Configure 'Build Lazarus'. Set Build LCL to 'Build'; set all others to 'None'. Also click 'qt' under LCL interface.
- Click the Build button.
- When Free Pascal is done compiling the LCL, check that you have newly created .ppu and .o files in /Users/login/Lazarus/lcl/units/powerpc-darwin/qt.
- Choose Tools | Configure, restore the LCL interface setting to 'gtk', then click 'Save settings'.
Creating an LCL app that uses the Qt widgetset
- Create a new project in Lazarus. When you started Lazarus, it created a new project -- you can use this.
- In Lazarus, choose Project | Compiler Options. On the Paths tab, select 'qt' under LCL Widget Type.
- On the Linking tab, select Pass Options To The Linker and enter
and click OK.
- Add one or more controls to your project's main form. Since the Qt widgetset is a work in progress, consult Roadmap#Widgetset_dependent_components to see which controls are working.
In the meantime qt widgetset becomes more mature, so you can see Lazarus Qt IDE under macOS
- Save the project to a folder in your home folder (/Users/login).
- In Lazarus, choose Run | Build to compile the project.
Tip: You can also compile your project from a script:
You can change most of the switches as needed, but be sure to leave the -k switches alone. If necessary, change the first line to the path to the LCL units you created in the previous section.
- Before running the app, make sure you've created an app bundle for it. You can copy the create_app_mac.sh script from section 6 to your project's folder and run it to create an app bundle for your compiled project.
- To run the app, double-click the application (not the executable file) in Finder or drag it to the dock and launch it from there.
- Before writing mac apps read macOS Human Interface guidelines.
Distributing an app that uses the Qt Interface Framework
- The Lazarus IDE creates a symbolic link inside the application bundle to the actual executable file. To copy the executable file into the application bundle in order to distribute it along with the application bundle, do this:
You should substitute the name of your application for 'MyApp' above.
- Consult Deploying Your Application#An Application Bundle for help with creating a distributable disk image file (.dmg extension) from your application bundle folder. Ignore the discussion of X11 and GTK since your app does not require them!
- Your application will depend on the Qt4 Framework Library and on the Qt4 Interface Binary Bindings. You can put these files inside your application bundle like you do with .dylib following macOS Programming Tips#Using a library in a Mac application.
- Read Deploying an Application on macOS about adding the Qt framework to your application bundle. Very handy for that purpose is the tool macdeployqt.
Uninstalling the Qt4 Interface and Qt4 Framework
- If you need to remove the Qt4 Interface from your computer, simply drag the Qt4Pas.framework folder from /Library/Frameworks to the trash. Finder will prompt you for your password before allowing this.
- If you need to remove the Qt4 Framework from your computer, simply drag the Qt3Support.framework and all QtXxxx.framework folders (like QtCore.framework, QtGui.framework, QtWebKit.framework ecc.) from /Library/Frameworks to the trash. Finder will prompt you for your password before allowing this.
- (Optional) You can also drag Qt4 Free Pascal Interface.pkg (if present) from /Library/Receipts to the trash.
Qt for Mac OS X has some requirements that are given in more detail in the Qt for Mac OS X Requirements document.
The following instructions describe how to install Qt from the source package.
For the binary package, simply double-click on the Qt.mpkg and follow the instructions to install Qt. You can later run the uninstall-qt.py
script to uninstall the binary package. The script is located in /Developer/Tools and must be run as root.
Note: Do not run the iPhone simulator while installing Qt. The iPhone simulator conflicts with the package installer.
Build Qt Macos
Step 1: Install the License File (commercial editions only)
If you have the commercial edition of Qt, install your license file as $HOME/.qt-license
.
For the open source version you do not need a license file.
Unpack the archive if you have not done so already. For example, if you have the qt-everywhere-opensource-src-%VERSION%.tar.gz
package, type the following commands at a command line prompt:
Qt Creator Mac Download
This creates the directory /tmp/qt-everywhere-opensource-src-%VERSION%
containing the files from the archive.
Step 2: Build the Qt Library
To configure the Qt library for your machine type, run the ./configure
script in the package directory.
By default, Qt is configured for installation in the /usr/local/Trolltech/Qt-%VERSION%
directory, but this can be changed by using the -prefix
option.
Type ./configure -help
to get a list of all available options.
Note that you will need to specify -universal
if you want to build universal binaries, and also supply a path to the -sdk
option if your development machine has a PowerPC CPU. By default, Qt is built as a framework, but you can built it as a set of dynamic libraries (dylibs) by specifying the -no-framework
option.
Qt can also be configured to be built with debugging symbols. This process is described in detail in the Debugging Techniques document.
To create the library and compile all the demos, examples, tools, and tutorials, type:
If -prefix
is outside the build directory, you need to install the library, demos, examples, tools, and tutorials in the appropriate place. To do this, type:
This command requires that you have administrator access on your machine.
Note: There is a potential race condition when running make install with multiple jobs. It is best to only run one make job (-j1) for the install.
If you later need to reconfigure and rebuild Qt from the same location, ensure that all traces of the previous configuration are removed by entering the build directory and typing make confclean
before running configure
again.
Step 3: Set the Environment variables
In order to use Qt, some environment variables need to be extended.
Build Standalone Qt Application For Mac
This is done like this:
In .profile
(if your shell is bash), add the following lines:
In .login
(in case your shell is csh or tcsh), add the following line:
If you use a different shell, please modify your environment variables accordingly.
That's all. Qt is now installed.
Qt Demos and Examples
If you are new to Qt, we suggest that you take a look at the demos and examples to see Qt in action. Run the Qt Examples and Demos either by typing qtdemo
on the command line or through the desktop's Start menu.
Build Qt For Mac Osx
You might also want to try the following links:
We hope you will enjoy using Qt. Good luck!
Build Qt For Mac Catalina
© 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.