Sign in Join
Wiki copytemporary

Legacy Information: Installing Lazarus on Mac: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Compatibility
22
33Not every combination of Lazarus and Free Pascal is compatible with every installation of the Mac operating system. Please refer to the following table in order to find the correct version for your development environment:
44
55## FPC 2.4.4 bug
66
77- FPC 2.4.4 has a bug. You can not compile the IDE with the range check flag **-Cr**.
88
99## Mac OS X 10.4 Tiger
1010
1111- On Mac OS X 10.4 Tiger you have to manually uninstall any previous version before installing a new dmg. Delete the following files and folders:
1212 - /Developer/lazarus
1313 - /Library/Receipts/lazarus.pkg
1414 - /etc/lazarus
1515 - /usr/local/bin/lazbuild
1616
1717## Installing Lazarus 2.0.8, 2.0.10 with FPC 3.2.0 for macOS 10.10 and earlier
1818
1919- \[Lazarus 2.0.8 only\] There is a patch required for Lazarus 2.0.8 so that the Cocoa widgetset can be compiled. See above.
2020
2121- \[Lazarus 2.0.8 + 2.0.10\] There is also a patch needed for FPC 3.2.0. Edit the FPC 3.2.0 source in `../packages/cocoaint/src/CocoaAll.pas` and comment out or remove the CoreImage linking line:
2222
2323``` pascal
2424 unit CocoaAll;
2525 interface
2626
2727 {$linkframework Cocoa}
2828 {$linkframework Foundation}
2929 //{$linkframework CoreImage} **Comment out this line**
3030 {$linkframework QuartzCore}
3131 {$linkframework CoreData}
3232 {$linkframework AppKit}
3333```
3434
3535- To rebuild FPC 3.2.0 with the patch, you need an FPC 3.0.4 binary installation. My `build_320.sh` shell script to rebuild and reinstall FPC 3.2.0 (adjust path for FPC source as required):
3636
3737``` sh
3838#!/bin/sh
3939cd /usr/local/share/src/fpc-3.2.0/
4040svn cleanup --remove-unversioned
4141make clean all FPC=/usr/local/lib/fpc/3.0.4/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"
4242make install FPC=/usr/local/lib/fpc/3.0.4/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64
4343```
4444
4545Note that:
4646
4747- if more than one line above is highlighted, all the highlighted content should be on one line;
4848- you may need to change the second line depending on where your FPC Source code is installed;
4949- you will almost certainly need to run the script by using `sudo`.
5050
5151Now rebuild Lazarus with this `build_laz.sh` shell script (adjust path for Lazarus source as required):
5252
5353``` sh
5454#!/bin/sh
5555cd ~/Documents/Lazarus/
5656svn cleanup --remove-unversioned
5757make distclean all LCL_PLATFORM=cocoa CPU_TARGET=x86_64 bigide
5858```
5959
6060## Installing Lazarus 2.0.8 with FPC 3.2.0 for macOS 10.11+
6161
6262- There is a patch needed for Lazarus 2.0.8 so that the Cocoa widgetset can be compiled:
6363
64-`Index: lcl/interfaces/cocoa/cocoascrollers.pas`\
65-`===================================================================`\
66-`--- lcl/interfaces/cocoa/cocoascrollers.pas     (revision 63408)`\
67-`+++ lcl/interfaces/cocoa/cocoascrollers.pas     (revision 63409)`\
68-`@@ -31,8 +31,6 @@`\
69-`   cocoa_extra, CocoaPrivate;`\
64+``` pascal
65+Index: lcl/interfaces/cocoa/cocoascrollers.pas
66+===================================================================
67+--- lcl/interfaces/cocoa/cocoascrollers.pas (revision 63408)
68++++ lcl/interfaces/cocoa/cocoascrollers.pas (revision 63409)
69+@@ -31,8 +31,6 @@
70+ cocoa_extra, CocoaPrivate;
7071
71-` type`\
72-`-  TSetDocumentViewType = {$if FPC_FULLVERSION = 30200}id{$else}NSView{$endif};`\
73-`-`\
74-`   { TCocoaScrollView }`\
72+ type
73+- TSetDocumentViewType = {$if FPC_FULLVERSION = 30200}id{$else}NSView{$endif};
74+-
75+ { TCocoaScrollView }
7576
76-`   TCocoaScrollView = objcclass(NSScrollView)`\
77-`@@ -51,7 +49,7 @@`\
78-`     procedure resetCursorRects; override;`\
79-`     function lclClientFrame: TRect; override;`\
80-`     function lclContentView: NSView; override;`\
81-`-    procedure setDocumentView(aView:  TSetDocumentViewType); override;`\
82-`+    procedure setDocumentView(aView: NSView); override;`\
83-`     procedure scrollContentViewBoundsChanged(notify: NSNotification); message 'scrollContentViewBoundsChanged:';`\
84-`     procedure resetScrollRect; message 'resetScrollRect';`\
77+ TCocoaScrollView = objcclass(NSScrollView)
78+@@ -51,7 +49,7 @@
79+ procedure resetCursorRects; override;
80+ function lclClientFrame: TRect; override;
81+ function lclContentView: NSView; override;
82+- procedure setDocumentView(aView: TSetDocumentViewType); override;
83++ procedure setDocumentView(aView: NSView); override;
84+ procedure scrollContentViewBoundsChanged(notify: NSNotification); message 'scrollContentViewBoundsChanged:';
85+ procedure resetScrollRect; message 'resetScrollRect';
8586
86-`@@ -647,7 +645,7 @@`\
87-`   Result:=documentView;`\
88-` end;`\
87+@@ -647,7 +645,7 @@
88+ Result:=documentView;
89+ end;
8990
90-`-procedure TCocoaScrollView.setDocumentView(aView: TSetDocumentViewType);`\
91-`+procedure TCocoaScrollView.setDocumentView(aView: NSView);`\
92-` begin`\
93-`   inherited setDocumentView(aView);`\
94-`   resetScrollRect;`
91+-procedure TCocoaScrollView.setDocumentView(aView: TSetDocumentViewType);
92++procedure TCocoaScrollView.setDocumentView(aView: NSView);
93+ begin
94+ inherited setDocumentView(aView);
95+ resetScrollRect;
96+```
9597
9698- After making this patch, recompile Lazarus 2.0.8 from within itself or with this `build_laz.sh` shell script (adjust path for Lazarus source as required):
9799
98100``` sh
99101#!/bin/sh
100102cd ~/Documents/Lazarus/
101103svn cleanup --remove-unversioned
102104make distclean all LCL_PLATFORM=cocoa CPU_TARGET=x86_64 bigide
103105```
104106
105107## macOS 10.5 Leopard
106108
107109- After installing Xcode 3.1 (includes the command line tools) for Leopard, the first issue is that Xcode 3.1 does not come with the Clang compiler.
108110
109111- - The solution is to create/add this to the .fpc.cfg file in your home directory:
110112
111-` #include /etc/fpc.cfg ## only add this line if the .fpc.cfg file does not already exist`\
112-` -WM10.5`\
113-` -Aas-darwin`
113+```text
114+ #include /etc/fpc.cfg ## only add this line if the .fpc.cfg file does not already exist
115+ -WM10.5
116+ -Aas-darwin
117+```
114118
115119- The second issue is that the official [Lazarus Mac OS X i386 download](https://sourceforge.net/projects/lazarus/files/Lazarus%20Mac%20OS%20X%20i386/Lazarus%202.0.10/) of FPC is FPC 3.0.4 and not 3.2.0.
116120 - The solution is to download the source for FPC 3.2.0 to your home directory. Open an Applications \> Utilities \> Terminal and:
117121
118-`   svn co `[`https://svn.freepascal.org/svn/fpc/tags/release_3_2_0`](https://svn.freepascal.org/svn/fpc/tags/release_3_2_0)` `
122+```text
123+ svn co https://svn.freepascal.org/svn/fpc/tags/release_3_2_0
124+```
119125
120126- The third issue is that the official [Lazarus Mac OS X i386 download](https://sourceforge.net/projects/lazarus/files/Lazarus%20Mac%20OS%20X%20i386/Lazarus%202.0.10/) for Lazarus 2.0.10 was compiled with FPC 3.0.4 and not FPC 3.2.0.
121127 - The solution is to download the Lazarus release sources to your home directory. Open an Applications \> Utilities \> Terminal and:
122128
123-`   svn co `[`https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10`](https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10)` `
129+```text
130+ svn co https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10
131+```
124132
125133- Compiling FPC 3.2.0 on Leopard is tricky (thanks to Jonas for supplying the solution). Before compiling FPC 3.2.0, make this change to the source so that it will not attempt to link the missing CoreImage framework. Then compile using the following `build_320.sh` script (enter your password at the prompt for the install to proceed):
126134
127135``` sh
128136 #!/bin/sh
129137 cd /Users/$USER/release_3_2_0/
130138 svn cleanup
131139 make clean all FPC="/usr/local/lib/fpc/3.0.4/ppc386" OS_TARGET=darwin CPU_TARGET=i386 CPU_SOURCE=i386 OPT="-WM10.5 -Aas-darwin -Xs-"
132140 sudo make install OS_TARGET=darwin CPU_TARGET=i386 CPU_SOURCE=i386
133141
134142```
135143
136144Note: The highlighted line above should all be on one line.
137145
138146- Compiling Lazarus 2.0.10 is less tricky. Before compiling Lazarus 2.0.10, make this change to the source so that the "run without debugging" option will work. I use the following `build_laz.sh` script:
139147
140148``` sh
141149 #!/bin/sh
142150 cd /Users/$USER/lazarus_2_0_10
143151 svn cleanup
144152 make distclean all LCL_PLATFORM=carbon CPU_SOURCE=i386 CPU_TARGET=i386 bigide OPT="-WM10.5 -Aas-darwin -Xs- -dCarbonDontUseCocoa"
145153
146154```
147155
148156Note: The highlighted line above should all be on one line.
149157
150158- Finally, launch the newly compiled lazarus.app and adjust these Lazarus settings:
151159 - Tools \> Options \> Environment \> Files \> Compiler executable: this should be set to **`/usr/local/bin/ppc386`**.
152160 - Project \> Project Options \> Custom Options: add **-WM10.5** to the Custom options.
153161 - Project \> Project Options \> Config and Target \> Target CPU family: set to **i386**.
154162 - Project \> Project Options \> Config and Target \> Current LCL widgetset: set to **Carbon**.
155163 - Project \> Project Options: in the left pane, at the bottom, **check** "Set compiler options as default".
156164
157165You should now be able to successfully compile and run the Lazarus default blank form project.
158166
159167## macOS 10.8 Mountain Lion additional steps
160168
161169- The first issue is that the official Lazarus pkg file downloads will not install on Mountain Lion, giving the error "Lazarus IDE cannot be installed on this disk" being the only disk in the system!
162170
163171- - The solution is to download the Lazarus release sources to your home directory. Open an Applications \> Utilities \> Terminal and:
164172
165-`   svn co `[`https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_8`](https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_8)\
166-`   =or=`\
167-`   svn co `[`https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10`](https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10)
173+```text
174+ svn co https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_8
175+ =or=
176+ svn co https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10
177+```
168178
169179- Unfortunately the compiler and assembler in the last version of Xcode and its command line tools available for Mountain Lion is too old to compile Lazarus.
170180 - The solution is to download the macOS Clang7 binary package from <https://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz>, uncompress it and install in your home directory.
171181 - Open an Applications \> Utilities \> Terminal and:
172182
173183``` bash
174184 cd /usr/bin
175185 sudo mv clang clang.OLD
176186 sudo ln -s /Users/$USER/clang/bin/clang clang
177187 sudo mv as as.OLD
178188 sudo ln -s /Users/$USER/clang/bin/as as
179189
180190```
181191
182192Now follow the steps above.
183193
184194## Resurrecting Subversion (svn) on Catalina, Big Sur and Monterey
185195
186196> **Note:** In August 2021, the Free Pascal Compiler and Lazarus IDE Projects moved their Subversion (svn) repositories to git and now host them on GitLab.com. The Lazarus IDE Project also mirrors their repository on GitHub.com which also allows access to the git repository using Subversion (svn).
187197
188198Xcode version 11.3.1 (Mojave) was the last version to include the Subversion (svn) utilities. You can however copy the utilities and their associated libraries from a Mojave Mac to Catalina, Big Sur and Monterey on both Intel and ARM64 processor Macs. There are two methods to do this - one uses Subversion from Xcode and the other uses Subversion from the command line tools as follows:
189199
190-`cd /Applications/Xcode.app/Contents/Developer/usr/bin`\
191-`scp svn* <remote_destination>`\
192-`cd /Applications/Xcode.app/Contents/Developer/usr/lib`\
193-`scp libsvn_*.dylib <remote_destination>`\
194-`scp libserf*.dylib <remote_destination>`
200+```text
201+cd /Applications/Xcode.app/Contents/Developer/usr/bin
202+scp svn* <remote_destination>
203+cd /Applications/Xcode.app/Contents/Developer/usr/lib
204+scp libsvn_*.dylib <remote_destination>
205+scp libserf*.dylib <remote_destination>
206+```
195207
196208OR
197209
198-`cd /Library/Developer/CommandLineTools/usr/bin`\
199-`scp svn* <remote_destination>`\
200-`cd /Library/Developer/CommandLineTools/usr/lib`\
201-`scp libsvn_*.dylib <remote_destination>`\
202-`scp libserf*.dylib <remote_destination>`
210+```text
211+cd /Library/Developer/CommandLineTools/usr/bin
212+scp svn* <remote_destination>
213+cd /Library/Developer/CommandLineTools/usr/lib
214+scp libsvn_*.dylib <remote_destination>
215+scp libserf*.dylib <remote_destination>
216+```
203217
204218## Installation - PowerPC-based Macs
205219
206220Download the three disk images (.dmg files) for fpc, fpcsrc and lazarus from the following link:
207221
208222- [PowerPC-based Macs](https://sourceforge.net/projects/lazarus/files/Lazarus%20Mac%20OS%20X%20powerpc/)
209223
210224Open up each disk image and install in this order:
211225
2122261. fpc
2132272. fpcsrc
2142283. Lazarus
215229
216230After installation the Lazarus application can be found in /Developer/lazarus/, the FPC source files in /usr/local/share/fpcsrc.
217231
218232If you receive a "Can't find unit Interfaces used by Project1" error on trying to compile a blank form, check the following settings in Lazarus (should be set by default):
219233
220234Environment Options
221235
222-`  Lazarus directory: /Developer/lazarus`\
223-`  Compiler path: /usr/local/bin/ppc386 (PowerPC Macs: /usr/local/bin/ppcppc)`\
224-`  FPC Source: /usr/local/share/fpcsrc`
236+```text
237+ Lazarus directory: /Developer/lazarus
238+ Compiler path: /usr/local/bin/ppc386 (PowerPC Macs: /usr/local/bin/ppcppc)
239+ FPC Source: /usr/local/share/fpcsrc
240+```
225241
226242Project \| Options
227243
228-`  All paths blank`\
229-`  LCL Widget Type: default (Carbon beta)`
244+``` pascal
245+ All paths blank
246+ LCL Widget Type: default (Carbon beta)
247+```
230248
231249Project \| Inspector
232250
233-`  Required Packages`\
234-`     LCL`\
251+```text
252+ Required Packages
253+ LCL
254+```
235255
236256Note - different versions of Lazarus depend on particular versions of the Free Pascal compiler and will not work with other versions.
237257
238258Another common problem is that the versions of fpc and fpcsrc are different.
239259
240260### Download stable sources
241261
242262The source code of stable versions is available in the [Lazarus Zip - GZip](http://sourceforge.net/projects/lazarus/files/Lazarus%20Zip%20_%20GZip/) archives. This is an option for users, who want to run the latest official Lazarus versions on "unsupported" machines, e.g. PPC-based Macs. Provided that you have installed the latest stable FPC version together with sources, it is sufficient to download and unpack the zip archive. Move it to the desired location (e.g. your /Developer folder), open a terminal window and change the shell's path to this folder (the easiest way to do this is to type "cd " and then to drag the icon of the freshly unpacked Lazarus folder to the position after this command in the Terminal window). If necessary enter \<return\> and then
243263
244-`[]$ make clean bigide`
264+```text
265+[]$ make clean bigide
266+```
245267
246268and \<return\> again. Subsequently, FreePascal will use the makefile in this folder to build the Lazarus IDE. This may take a few minutes, but the process is fully automated. Therefore, you might want to look for a cup of coffee, while FPC is working. If the compiler is ready it prints the number of processed lines and the required time to the shell's output.
247269
248270The last step is to right-klick on the Lazarus bundle icon and to select "Show Package Contents" from the context menu. Then drag the executable "lazarus" to the folder "Contents/MacOS" of the bundle. That's it.
249271
250272## Installing gdb
251273
252274As of the Lazarus 2.0.0 release this is entirely optional. The IDE now supports LLDB directly. See <http://forum.lazarus-ide.org/index.php/topic,42869.0.html> and <http://wiki.lazarus.freepascal.org/Lazarus_2.0.0_release_notes#LLDB_based_Debugger_.28New.29>
253275
254276Getting gdb to run can be a bit tedious but is worthwhile in the end if using Lazarus \< V2.0 or have some specific requirement for gdb. You probably don't !
255277
256278This step should be done after installing XCode and before installing FPC/Lazarus.
257279
2582801. Install fink or brew and use them to install gdb- <http://wiki.freepascal.org/GDB_on_OS_X_Mavericks_and_Xcode_5>
2592812. Self sign the gdb binary using tools already on your Mac - <https://sourceware.org/gdb/wiki/BuildingOnDarwin> This is the tedious part. The instructions are clear except, perhaps they could have mentioned that after you have set the Keychain to ’System’ you need click ‘Create’ and ‘Done’ on the next screen. Then go and find the cert in your overall list of certs to do the next instruction “using the contextual menu…”. Don’t worry about step “2.1.4 Disable starting the debuggee…”, we’ll address that once Lazarus itself is installed and working.
2602823. Once Lazarus is installed and fired up, tell it how it should start gdb, that is step 5.
261283
262284**Note** that as of April 2018, there may be issues with newest gdb and High Sierra. <https://forum.lazarus.freepascal.org/index.php/topic,40874.0.html> *According to <https://stackoverflow.com/questions/49001329/gdb-doesnt-work-on-macos-high-sierra-10-13-3>, gdb 8.1 does not work on High Sierra, but 8.0.1 does.*
263285
264286**Part 2 of gdb install, Tell Lazarus about starting gdb**
265287
266288Again, this step is not necessary with Lazarus V2.0 and later. See <http://wiki.lazarus.freepascal.org/Lazarus_2.0.0_release_notes#LLDB_based_Debugger_.28New.29> If you do install (and use) gdb, you must tell Lazarus about how to call gdb. Obviously, this step happens after Lazarus is installed.
267289
268290OK, now you should be able to start Lazarus, it should display the various parts and paths it needs (including gdb) in the little opening screen. You will get an alert there if you chose to not use a debugger. Proceed to the IDE and we now need to tell Lazarus to tell gdb to not open a shell, as noted by a number of Forum users (http://forum.lazarus.freepascal.org/index.php/topic,37310.0.html). Within Lazarus, click Tools \> Options \> Debugger \> General In the “Debugger specific Options” there is a field labeled Debugger_Startup_Options. Type in "--eval-command=set startup-with-shell off" (including the inverted commas) AND press the return key, click OK. Note you cannot copy and paste into this box (##\$!). See screen shot.
269291
270292![](/wiki-images/6/6e/Debug_Startup_Options_01.png)
271293
272294## Xcode Compatability
273295
274296Information relating to older versions of FPC, Lazarus and Apple Developer Tools
275297
276298### Compatibility with Xcode 5.0 and newer versions (OS X 10.8, 10.9, 10.10 and 10.11)
277299
278300Like Xcode 4.3+, Xcode 5 and subsequent versions no longer install the command line tools by default. These are required by FPC/Lazarus, however. Unlike in Xcode 4, the installation option is no longer accessible in Xcode 5 via the Downloads tab. Additionally, the "Locations" tab of the preferences dialog may be confusing, as it mentions that the command line tools are installed:
279301
280302![](/wiki-images/f/f6/Xcode5_misleading_screenshot.png)
281303
282304Default location of command line tools in Xcode 5.
283305
284306![](/wiki-images/9/95/Xcode_select.png)
285307
286308Installation of command line tools with the xcode-select command part 1...
287309
288310![](/wiki-images/7/75/Command_line_tools_installation_on_mavericks.png)
289311
290312...and part 2.
291313
292314The first dialog box shows that by default the command line tools are only installed inside the Xcode.app bundle itself. To install them globally, as required by FPC/Lazarus, execute the following terminal command:
293315
294316``` bash
295317xcode-select --install
296318```
297319
298320Depending from your Xcode version alternative steps to install the command line developer tools may be to download them directly in the Xcode preferences window (see screenshots above) or to download them from [developer.apple.com](http://developer.apple.com) (please take care to install the command line tools that are correct exactly for your Xcode version).
299321
300322- You can compile and install the normal gdb. See [[GDB on OS X Mavericks and Xcode 5]].
301323
302324### Xcode 4.3+ compatibility (Mac OS X 10.7 / OS X 10.8)
303325
304326Xcode 4.3 and later no longer install the command line tools by default. These are required by FPC/Lazarus.
305327
306328To install them manually, open Xcode, go to Preferences, select "Downloads;" and install the "Command Line Tools". Afterwards, FPC will install and function correctly.
307329
308330![](/wiki-images/0/0b/Install_command_line_tools_1.png)
309331
310332![](/wiki-images/b/bf/Install_command_line_tools_2.png)
311333
312334![](/wiki-images/4/49/Install_command_line_tools_3.png)
313335
314336It will be necessary to reinstall the command line tools after each upgrade of Xcode (especially when it's a new major version, the installer may delete the old copies of the command line tools), and also after switching to a new major version of the system software (idem). You may also download the command line tools from [Apple Developer](https://developer.apple.com/download/more/?=command%20line%20tools).
315337
316338### Xcode 3.2.x compatibility (Mac OS X 10.6)
317339
318340FPC 2.6.0: there is an issue when compiling dynamic libraries with FPC under Mac OS X 10.6 due to a bug in the Xcode 3.2.x linker. This bug has been fixed in Xcode 4. You can work around the bug in Xcode 3.2.x by using the -k-no_order_inits command line parameter when compiling a dynamic library.
319341
320342### Xcode 3.1.x compatibility (Mac OS X 10.5)
321343
322344Most versions of Lazarus and FPC are compatible with Xcode 3.1 (see the compatibility matrix for detailed reference). The Xcode integration kit is provided as an optional install to allow for developing with Free Pascal directly from Xcode. It is not required for development with Lazarus, however.
323345
324346### Xcode 2.x compatibility (Mac OS X 10.4)
325347
326348Most versions of Lazarus and FPC are compatible with Xcode 2.3 or newer (see the compatibility matrix for detailed reference). The Xcode integration kit is provided as an optional install to allow for developing with Free Pascal directly from Xcode. It is not required for development with Lazarus, however. Xcode 2.0 was compatible with Lazarus 0.9.x, but it is no longer supported by newer versions of the Lazarus IDE.
327349
328350---
329351*From the Free Pascal wiki, page "Legacy Information: Installing Lazarus on Mac", as it stood on 2022-06-02 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history