Difference between revisions of "Qt Interface Mac"

From Lazarus wiki
Jump to navigationJump to search
(Revised for 1.14)
(Added links to Den's downloads)
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
  
Sections 2, 3, and 4 only need to be done if you are creating the Qt libraries, interface library, and interface framework yourself. If you have installed the interface framework using Qt4IntfFramework_PowerPC.dmg (in file mac_bin-qt4pas-1.xx.zip), you can start with section 5.
+
Sections 2, 3, and 4 only need to be done if you are creating the Qt libraries, interface library, and interface framework yourself. If you have installed the interface framework using Qt4IntfFramework_PowerPC.dmg (in file [http://users.pandora.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html mac_bin-qt4pas-1.xx.zip]), you can start with section 5.
  
 
'''Notes on terminology:'''
 
'''Notes on terminology:'''
Line 9: Line 9:
 
If you're not familiar with OS X terms such as "framework" and "app bundle", refer to Apple's extensive online documentation.
 
If you're not familiar with OS X 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'll probably need to change its permission so that OS X will allow it to be executed:
+
'''''Important!''''' To run any of the scripts mentioned in sections 3-6, you may need to change its permission so that OS X will allow it to be executed:
  
 
<pre> chmod +x script_name.sh</pre>
 
<pre> chmod +x script_name.sh</pre>
Line 51: Line 51:
 
==Creating the Qt interface library==
 
==Creating the Qt interface library==
  
A script file for doing this is included with mac_qt4pas-1.xx.zip. Download and double-click this file to create folder qt4pas-1.xx. Move this folder to your home folder (/Users/login) and change to it (cd). Run the script as follows:
+
A script file for doing this is included with [http://users.pandora.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html mac_qt4pas-1.xx.zip]. Download and double-click this file to create folder qt4pas-1.xx. Move this folder to your home folder (/Users/login) and change to it (cd). Run the script as follows:
  
 
<pre> ./compile_lib_mac.sh</pre>
 
<pre> ./compile_lib_mac.sh</pre>
Line 71: Line 71:
 
==Compiling the non-Lazarus demo programs with Free Pascal==
 
==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).
+
The Pascal source for several demo programs is included in file [http://users.pandora.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html 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).
  
 
If necessary, copy the qt4.pas file into the demo folder. The qt4.pas file can be found in mac_qt4pas-1.xx.zip or mac_bin-qt4pas-1.xx.zip.
 
If necessary, copy the qt4.pas file into the demo folder. The qt4.pas file can be found in mac_qt4pas-1.xx.zip or mac_bin-qt4pas-1.xx.zip.

Revision as of 23:15, 12 May 2006

Introduction

Sections 2, 3, and 4 only need to be done if you are creating the Qt libraries, interface library, and interface framework yourself. If you have installed the interface framework using Qt4IntfFramework_PowerPC.dmg (in file mac_bin-qt4pas-1.xx.zip), you can start with section 5.

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 OS X-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.

If you're not familiar with OS X 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 OS X will allow it to be executed:

 chmod +x script_name.sh

Creating the Qt libraries from Qt Open Source Edition

2.1. Download the Qt Open Source from Trolltech's Web site. This file will be named something like qt-mac-opensource-src-4.1.1.tar.gz.

2.2. Double-click the file and let StuffIt expand it to a folder with the same name but without the .tar.gz extension.

2.3. Move the resulting folder to your home folder (/Users/login).

2.4. Make sure the OS X DevSDK package is installed. With OS X 10.3, this package is on the XCode Tools CD.

2.5. Open a Terminal window.

2.6. Change to the Qt source folder:

 cd ~/qt-mac-opensource-src-4.1.1

2.7. Enter this command:

 ./configure

2.8. Enter yes when prompted. When done configuring, a message will be outputted.

2.9. Enter this command:

 make

This will compile the source with a GNU Compiler Collection (GCC) c++ compiler that's part of the OS X DevSDK package. This compilation will create QtCore.framework and QtGui.framework in the Qt source's lib folder. These frameworks contain the Qt libraries that we will be using.

Important! Compilation may take several hours depending on the speed of your computer.

2.10. Optional. If for some reason you don't want to create and use the Qt interface framework, you will need to install the resulting Qt libraries to /usr/local/Trolltech by entering this command:

 sudo make install

Creating the Qt interface library

A script file for doing this is included with mac_qt4pas-1.xx.zip. Download and double-click this file to create folder qt4pas-1.xx. Move this folder to your home folder (/Users/login) and change to it (cd). Run the script as follows:

 ./compile_lib_mac.sh

This script will use the GCC g++ compiler to compile qtpas.cpp and create Qt4Intf, the Qt interface library. If the script can't find the Qt libraries, it will output an error message -- this will happen if you're using a different version of the Qt source than the script expects. To fix this error, edit the script and make sure the QT4 setting specifies the path to your Qt source folder.

Creating the Qt interface framework

A script file for doing this is included with mac_qt4pas-1.xx.zip. Run the script as follows:

 sudo ./create_framework_mac.sh

This creates the Qt4Intf.framework folder under /Library/Frameworks and copies the Qt libraries and Qt interface library to it. For more information, take a look at the script.

Note that sudo is required because of the need to copy into the /Library folder.

If the script can't find the Qt libraries it needs, it will output an error message -- you may need to edit the script to make sure the Qt4 setting specifies the path to your Qt source folder.

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).

If necessary, copy the qt4.pas file into the demo folder. The qt4.pas file can be found in mac_qt4pas-1.xx.zip or mac_bin-qt4pas-1.xx.zip.

To compile one of the demo programs:

 cd somedemo
 ln -s ../qt4.pas qt4.pas
 ../compile_exe_fr_mac.sh somedemo

This will compile the demo program with Free Pascal, creating an executable file with the same name.

Tip: The ln command creates a symbolic link to the qt4.pas file and allows you to use a single copy of qt4.pas to compile all the demo programs. Normally with your own programs you would copy qt4.pas into your source folder and the ln command would not be necessary.

Note that Lazarus is not required to compile these demo programs.

Creating a demo program application bundle

To create a double-clickable application on OS X, 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:

 ../create_app_mac.sh somedemo

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.