Sign in Join
Wiki copytemporary

Legacy Information: Installing Lazarus on Mac: what changed

Revision 1 to 2. 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
6464`Index: lcl/interfaces/cocoa/cocoascrollers.pas`\
6565`===================================================================`\
6666`--- lcl/interfaces/cocoa/cocoascrollers.pas     (revision 63408)`\
6767`+++ lcl/interfaces/cocoa/cocoascrollers.pas     (revision 63409)`\
6868`@@ -31,8 +31,6 @@`\
6969`   cocoa_extra, CocoaPrivate;`\
7070
7171` type`\
7272`-  TSetDocumentViewType = {$if FPC_FULLVERSION = 30200}id{$else}NSView{$endif};`\
7373`-`\
7474`   { TCocoaScrollView }`\
7575
7676`   TCocoaScrollView = objcclass(NSScrollView)`\
7777`@@ -51,7 +49,7 @@`\
7878`     procedure resetCursorRects; override;`\
7979`     function lclClientFrame: TRect; override;`\
8080`     function lclContentView: NSView; override;`\
8181`-    procedure setDocumentView(aView:  TSetDocumentViewType); override;`\
8282`+    procedure setDocumentView(aView: NSView); override;`\
8383`     procedure scrollContentViewBoundsChanged(notify: NSNotification); message 'scrollContentViewBoundsChanged:';`\
8484`     procedure resetScrollRect; message 'resetScrollRect';`\
8585
8686`@@ -647,7 +645,7 @@`\
8787`   Result:=documentView;`\
8888` end;`\
8989
9090`-procedure TCocoaScrollView.setDocumentView(aView: TSetDocumentViewType);`\
9191`+procedure TCocoaScrollView.setDocumentView(aView: NSView);`\
9292` begin`\
9393`   inherited setDocumentView(aView);`\
9494`   resetScrollRect;`
9595
9696- 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):
9797
9898``` sh
9999#!/bin/sh
100100cd ~/Documents/Lazarus/
101101svn cleanup --remove-unversioned
102102make distclean all LCL_PLATFORM=cocoa CPU_TARGET=x86_64 bigide
103103```
104104
105105## macOS 10.5 Leopard
106106
107107- 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.
108108
109109- - The solution is to create/add this to the .fpc.cfg file in your home directory:
110110
111111` #include /etc/fpc.cfg ## only add this line if the .fpc.cfg file does not already exist`\
112112` -WM10.5`\
113113` -Aas-darwin`
114114
115115- 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.
116116 - The solution is to download the source for FPC 3.2.0 to your home directory. Open an Applications \> Utilities \> Terminal and:
117117
118118`   svn co `[`https://svn.freepascal.org/svn/fpc/tags/release_3_2_0`](https://svn.freepascal.org/svn/fpc/tags/release_3_2_0)` `
119119
120120- 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.
121121 - The solution is to download the Lazarus release sources to your home directory. Open an Applications \> Utilities \> Terminal and:
122122
123123`   svn co `[`https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10`](https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10)` `
124124
125125- 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):
126126
127127``` sh
128128 #!/bin/sh
129129 cd /Users/$USER/release_3_2_0/
130130 svn cleanup
131131 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-"
132132 sudo make install OS_TARGET=darwin CPU_TARGET=i386 CPU_SOURCE=i386
133133
134134```
135135
136136Note: The highlighted line above should all be on one line.
137137
138138- 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:
139139
140140``` sh
141141 #!/bin/sh
142142 cd /Users/$USER/lazarus_2_0_10
143143 svn cleanup
144144 make distclean all LCL_PLATFORM=carbon CPU_SOURCE=i386 CPU_TARGET=i386 bigide OPT="-WM10.5 -Aas-darwin -Xs- -dCarbonDontUseCocoa"
145145
146146```
147147
148148Note: The highlighted line above should all be on one line.
149149
150150- Finally, launch the newly compiled lazarus.app and adjust these Lazarus settings:
151151 - Tools \> Options \> Environment \> Files \> Compiler executable: this should be set to **`/usr/local/bin/ppc386`**.
152152 - Project \> Project Options \> Custom Options: add **-WM10.5** to the Custom options.
153153 - Project \> Project Options \> Config and Target \> Target CPU family: set to **i386**.
154154 - Project \> Project Options \> Config and Target \> Current LCL widgetset: set to **Carbon**.
155155 - Project \> Project Options: in the left pane, at the bottom, **check** "Set compiler options as default".
156156
157157You should now be able to successfully compile and run the Lazarus default blank form project.
158158
159159## macOS 10.8 Mountain Lion additional steps
160160
161161- 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!
162162
163163- - The solution is to download the Lazarus release sources to your home directory. Open an Applications \> Utilities \> Terminal and:
164164
165165`   svn co `[`https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_8`](https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_8)\
166166`   =or=`\
167167`   svn co `[`https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10`](https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_10)
168168
169169- 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.
170170 - 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.
171171 - Open an Applications \> Utilities \> Terminal and:
172172
173173``` bash
174174 cd /usr/bin
175175 sudo mv clang clang.OLD
176176 sudo ln -s /Users/$USER/clang/bin/clang clang
177177 sudo mv as as.OLD
178178 sudo ln -s /Users/$USER/clang/bin/as as
179179
180180```
181181
182182Now follow the steps above.
183183
184184## Resurrecting Subversion (svn) on Catalina, Big Sur and Monterey
185185
186186> **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).
187187
188188Xcode 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:
189189
190190`cd /Applications/Xcode.app/Contents/Developer/usr/bin`\
191191`scp svn* <remote_destination>`\
192192`cd /Applications/Xcode.app/Contents/Developer/usr/lib`\
193193`scp libsvn_*.dylib <remote_destination>`\
194194`scp libserf*.dylib <remote_destination>`
195195
196196OR
197197
198198`cd /Library/Developer/CommandLineTools/usr/bin`\
199199`scp svn* <remote_destination>`\
200200`cd /Library/Developer/CommandLineTools/usr/lib`\
201201`scp libsvn_*.dylib <remote_destination>`\
202202`scp libserf*.dylib <remote_destination>`
203203
204204## Installation - PowerPC-based Macs
205205
206206Download the three disk images (.dmg files) for fpc, fpcsrc and lazarus from the following link:
207207
208208- [PowerPC-based Macs](https://sourceforge.net/projects/lazarus/files/Lazarus%20Mac%20OS%20X%20powerpc/)
209209
210210Open up each disk image and install in this order:
211211
2122121. fpc
2132132. fpcsrc
2142143. Lazarus
215215
216216After installation the Lazarus application can be found in /Developer/lazarus/, the FPC source files in /usr/local/share/fpcsrc.
217217
218218If 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):
219219
220220Environment Options
221221
222222`  Lazarus directory: /Developer/lazarus`\
223223`  Compiler path: /usr/local/bin/ppc386 (PowerPC Macs: /usr/local/bin/ppcppc)`\
224224`  FPC Source: /usr/local/share/fpcsrc`
225225
226226Project \| Options
227227
228228`  All paths blank`\
229229`  LCL Widget Type: default (Carbon beta)`
230230
231231Project \| Inspector
232232
233233`  Required Packages`\
234234`     LCL`\
235235
236236Note - different versions of Lazarus depend on particular versions of the Free Pascal compiler and will not work with other versions.
237237
238238Another common problem is that the versions of fpc and fpcsrc are different.
239239
240240### Download stable sources
241241
242242The 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
243243
244244`[]$ make clean bigide`
245245
246246and \<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.
247247
248248The 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.
249249
250250## Installing gdb
251251
252252As 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>
253253
254254Getting 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 !
255255
256256This step should be done after installing XCode and before installing FPC/Lazarus.
257257
2582581. Install fink or brew and use them to install gdb- <http://wiki.freepascal.org/GDB_on_OS_X_Mavericks_and_Xcode_5>
2592592. 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.
2602603. Once Lazarus is installed and fired up, tell it how it should start gdb, that is step 5.
261261
262262**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.*
263263
264264**Part 2 of gdb install, Tell Lazarus about starting gdb**
265265
266266Again, 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.
267267
268268OK, 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.
269269
270-Image:Debug_Startup_Options_01.png
270+![](/wiki-images/6/6e/Debug_Startup_Options_01.png)
271271
272272## Xcode Compatability
273273
274274Information relating to older versions of FPC, Lazarus and Apple Developer Tools
275275
276276### Compatibility with Xcode 5.0 and newer versions (OS X 10.8, 10.9, 10.10 and 10.11)
277277
278278Like 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:
279279
280-Image:xcode5 misleading screenshot.png\|Default location of command line tools in Xcode 5. Image:xcode select.png\|Installation of command line tools with the xcode-select command part 1... Image:command line tools installation on mavericks.png\|...and part 2.
280+![](/wiki-images/f/f6/Xcode5_misleading_screenshot.png)
281281
282+Default location of command line tools in Xcode 5.
283+
284+![](/wiki-images/9/95/Xcode_select.png)
285+
286+Installation of command line tools with the xcode-select command part 1...
287+
288+![](/wiki-images/7/75/Command_line_tools_installation_on_mavericks.png)
289+
290+...and part 2.
291+
282292The 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:
283293
284294``` bash
285295xcode-select --install
286296```
287297
288298Depending 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).
289299
290300- You can compile and install the normal gdb. See [[GDB on OS X Mavericks and Xcode 5]].
291301
292302### Xcode 4.3+ compatibility (Mac OS X 10.7 / OS X 10.8)
293303
294304Xcode 4.3 and later no longer install the command line tools by default. These are required by FPC/Lazarus.
295305
296306To install them manually, open Xcode, go to Preferences, select "Downloads;" and install the "Command Line Tools". Afterwards, FPC will install and function correctly.
297307
298-Image:install command line tools 1.png Image:install command line tools 2.png Image:install command line tools 3.png
308+![](/wiki-images/0/0b/Install_command_line_tools_1.png)
309+
310+![](/wiki-images/b/bf/Install_command_line_tools_2.png)
311+
312+![](/wiki-images/4/49/Install_command_line_tools_3.png)
299313
300314It 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).
301315
302316### Xcode 3.2.x compatibility (Mac OS X 10.6)
303317
304318FPC 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.
305319
306320### Xcode 3.1.x compatibility (Mac OS X 10.5)
307321
308322Most 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.
309323
310324### Xcode 2.x compatibility (Mac OS X 10.4)
311325
312326Most 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.
313327
314328---
315329*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