Difference between revisions of "Build current FPC and Lazarus for Raspbian"

From Lazarus wiki
Jump to navigationJump to search
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{Lazarus Documentation}}
 +
 
Raspbian Buster (based on Debian 10 Buster) has FPC and Lazarus available in the repositories, but they suffer from the same "design decisions" that don't allow for a nice experience, namely the smooth IDE rebuilding capability based on source packages that is possible with FPC/Lazarus official .deb packages vs the crippled experience with the official Debian/Raspbian packages. One wishes there were official FPC/Lazarus packages for Raspbian as there are for Intel Debian/Ubuntu, which are also frequently updated; not being that the case (at least for now), this page shows the steps for building your own FPC, FPC-source and Lazarus packages for Raspbian. Example shows steps for Lazarus 2.0.6 which includes FPC 3.0.4, most recent at the time of writing. Adjust accordingly.
 
Raspbian Buster (based on Debian 10 Buster) has FPC and Lazarus available in the repositories, but they suffer from the same "design decisions" that don't allow for a nice experience, namely the smooth IDE rebuilding capability based on source packages that is possible with FPC/Lazarus official .deb packages vs the crippled experience with the official Debian/Raspbian packages. One wishes there were official FPC/Lazarus packages for Raspbian as there are for Intel Debian/Ubuntu, which are also frequently updated; not being that the case (at least for now), this page shows the steps for building your own FPC, FPC-source and Lazarus packages for Raspbian. Example shows steps for Lazarus 2.0.6 which includes FPC 3.0.4, most recent at the time of writing. Adjust accordingly.
  
Line 20: Line 22:
 
# <code>cd ~/pascal</code>
 
# <code>cd ~/pascal</code>
 
# <code>svn co <nowiki>https://svn.freepascal.org/svn/fpc/tags/release_3_0_4</nowiki> fpc</code>, you have to be online for this and the next step to work.
 
# <code>svn co <nowiki>https://svn.freepascal.org/svn/fpc/tags/release_3_0_4</nowiki> fpc</code>, you have to be online for this and the next step to work.
# <code>svn co <nowiki>https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_6</nowiki> lazarus</code>
+
# <code>svn co <nowiki>https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_8</nowiki> lazarus</code>
 
# <code>cd lazarus/tools/install</code>
 
# <code>cd lazarus/tools/install</code>
 
# Edit <code>create_fpc_deb.sh</code>, look for line with the following content: <code>arm)    ppcbin=arm;  FPCArch=arm;;</code>, (currently line 109). Copy and paste this line below itself, so it will appear twice. Edit this copy to read like this: <code>armhf)  ppcbin=arm;  FPCArch=arm;;</code>. Now save the changes and exit.
 
# Edit <code>create_fpc_deb.sh</code>, look for line with the following content: <code>arm)    ppcbin=arm;  FPCArch=arm;;</code>, (currently line 109). Copy and paste this line below itself, so it will appear twice. Edit this copy to read like this: <code>armhf)  ppcbin=arm;  FPCArch=arm;;</code>. Now save the changes and exit.
Line 28: Line 30:
 
# Install the just created FPC Debian package: <code>sudo dpkg -i ~/pascal/lazarus/tools/install/fpc-laz_3.0.4_armhf.deb</code>. Check if it works: <code>fpc abcd</code> should show the newly installed FPC compiler.
 
# Install the just created FPC Debian package: <code>sudo dpkg -i ~/pascal/lazarus/tools/install/fpc-laz_3.0.4_armhf.deb</code>. Check if it works: <code>fpc abcd</code> should show the newly installed FPC compiler.
 
# <code>cd ~/pascal/lazarus/tools/install</code>
 
# <code>cd ~/pascal/lazarus/tools/install</code>
# <code>./create_fpc_deb.sh fpc-src ~/pascal/fpc/</code>. This builds the FPC source package in about 3 minutes: <code>fpc-src_3.0.4-yymmdd_armhf.deb</code>. Rename to <code>fpc-src_3.0.4_armhf.deb</code>
+
# <code>./create_fpc_deb.sh fpc-src ~/pascal/fpc/</code>. This builds the FPC source package in about 3 minutes: <code>fpc-src_3.0.4-yymmdd_armhf.deb</code>. Rename with: mv <code>fpc-src_3.0.4-yymmdd_armhf.deb</code> <code>fpc-src_3.0.4_armhf.deb</code>
# Edit <code>create_lazarus_deb.sh</code>, look for line with the following content: <code>echo "$Arch is not supported."</code>, (currently line 86). Copy the 3 lines above it and paste them just below themselves: at this time it is copy lines 83 to 85 and paste them between lines 85 and 86. In the just pasted lines (lines 86-88), replace <code>sparc</code> with <code>armhf</code>, and <code>ppcsparc</code> with <code>ppcarm</code>. Look for the first <code>fi</code> just below; copy and paste it below itself (copy line 91 below itself, so line 91 and 92 read the same). For you coders out there, you are adding another <code>if</code> to a nested <code>if</code>, with its corresponding <code>fi</code>.
+
# Edit <code>create_lazarus_deb.sh</code>, look for line with the following content: <code>echo "$Arch is not supported."</code>, (currently line 86). Copy the 3 lines above it and paste them just below themselves: at this time it is copy lines 83 to 85 and paste them between lines 85 and 86. In the just pasted lines (lines 86-88), replace <code>sparc</code> with <code>armhf</code>, and <code>ppcsparc</code> with <code>ppcarm</code>. Look for the first <code>fi</code> just below; copy and paste it below itself (copy line 91 below itself, so line 91 and 92 read the same). For you coders out there, you are adding another <code>if</code> to a nested <code>if</code>, with its corresponding <code>fi</code>. Now save and exit.
# <code>./create_lazarus_deb.sh</code>. This will build the Lazarus IDE Debian package <code>lazarus-project_2.0.6-0_armhf.deb</code>. It will take about 15 minutes.
+
# <code>./create_lazarus_deb.sh</code>. This will build the Lazarus IDE Debian package <code>lazarus-project_2.0.8-0_armhf.deb</code>. It will take about 15 minutes.
# Install the FPC source and Lazarus packages: <code>sudo dpkg -i fpc-src_3.0.4_armhf.deb lazarus-project_2.0.6-0_armhf.deb</code>
+
# Install the FPC source and Lazarus packages: <code>sudo dpkg -i fpc-src_3.0.4_armhf.deb lazarus-project_2.0.8-0_armhf.deb</code>
 
# Save <code>*.deb</code> to another location, to reinstall later if needed or to share with friends: remember this is free software.
 
# Save <code>*.deb</code> to another location, to reinstall later if needed or to share with friends: remember this is free software.
 
# <code>cd</code>, <code>rm -rf ~/pascal ~/tmp</code>
 
# <code>cd</code>, <code>rm -rf ~/pascal ~/tmp</code>
Line 38: Line 40:
  
 
Want to help the FPC/Lazarus community? Host the resulting <code>.deb</code> packages somewhere on the Internet and drop a note on the forum to let everyone know; rinse and repeat for every release.
 
Want to help the FPC/Lazarus community? Host the resulting <code>.deb</code> packages somewhere on the Internet and drop a note on the forum to let everyone know; rinse and repeat for every release.
 +
 +
DISCLAIMER: these are UNOFFICIAL packages created from modified official sources. DO NOT ASK FOR SUPPORT ANYWHERE, neither on the forums or with the author of this article; use at your own risk.
 +
 +
===Upgrading===
 +
 +
The following is not written by whoever worked out this process in the first place.  It is completely un-authoritative, but it worked for me to upgrade from Laz 2.0.8 to 2.0.10.  I make no other claims what-so-ever - Use at your own risk.  ''The bracketed numbers in the steps refer back to the original version (until someone edits it)''
 +
 +
Once you have followed the above steps once, you can shortcut the process a little to upgrade.  In particular, Steps 1 - 8 should not be necessary, as we have the previous version already installed.
 +
 +
# (9) Update development libraries: <code>sudo apt upgrade libgtk2.0-dev libgpm-dev libncurses-dev</code>
 +
# (10) if required, <code>mkdir ~/pascal</code>
 +
# (11) <code> cd ~/pascal</code>
 +
# If you didn't clean out the temp files from last time, do so now:  <code>rm -rf fpc lazarus</code>
 +
# (12) <code>svn co <nowiki>https://svn.freepascal.org/svn/fpc/tags/</nowiki>''[required-release]'' fpc</code>.  ''(if necessary, browse https://svn.freepascal.org/svn/fpc/tags to find the exact release.)''
 +
# (13) <code>svn co <nowiki>https://svn.freepascal.org/svn/lazarus/tags/</nowiki>''[required-release]'' lazarus</code>.  ''(if necessary, browse https://svn.freepascal.org/svn/lazarus/tags to find the exact release.)''
 +
# (14) <code>cd lazarus/tools/install</code>
 +
# (15) Edit <code>create_fpc_deb.sh</code>, look for line with the following content: <code>arm)    ppcbin=arm;  FPCArch=arm;;</code>, (currently line 109).
 +
## Copy and paste this line below itself, so it will appear twice.
 +
## Edit this copy to read like this: <code>armhf)  ppcbin=arm;  FPCArch=arm;;</code>. Now save the changes and exit.
 +
# (16) Run the script: <code>./create_fpc_deb.sh fpc ~/pascal/fpc/</code>. This will compile the latest compiler with the bootstrap compiler. It takes about 11 minutes. A <code>.deb</code> file will be created: <code>fpc-laz_''[fpc release]''-yymmdd_armhf.deb</code>; the exact name will be shown at the end of the compilation.
 +
# Rename the file with (NOTE: do not type the brackets): <code>mv ''[file name shown at end of compilation]'' fpc-laz_''[fpc release]''_armhf.deb</code>
 +
# (17) You have completed the FPC build. ''Rebooting the Pi should '''not''' be necessary, as we made no temporary PATH.  (Yay)''
 +
# (18) Check/uninstall the bootstrap FPC: <code>rm -rf ~/.fpc.cfg ~/.config/fppkg.cfg ~/.fppkg ~/fpc-''[fpc_release]'' ~/tmp</code>. ''(If you cleaned up after the initial build, you should only find <code>~/tmp</code> this time)''
 +
# Check what you just did: <code>fpc abcd</code> should say command is not found.
 +
# (19) Install the just created FPC Debian package: <code>sudo dpkg -i ~/pascal/lazarus/tools/install/fpc-laz_''[fpc-release]''_armhf.deb</code>. ''(-i can also upgrade - the message should be "installing [new ver] over [old ver]")''
 +
# Check if it works: <code>fpc abcd</code> should show the newly installed FPC compiler.
 +
# (20) <code>cd ~/pascal/lazarus/tools/install</code>
 +
# (21) <code>./create_fpc_deb.sh fpc-src ~/pascal/fpc/</code>. This builds the FPC source package <code>fpc-src_''[fpc-release]''-yymmdd_armhf.deb</code> in about 3 minutes.
 +
# Rename with: <code>mv fpc-src_''[fpc-release]-yymmdd''_armhf.deb</code> <code>fpc-src_''[fpc-release]''_armhf.deb</code>
 +
# (22) Edit <code>create_lazarus_deb.sh</code>,
 +
## Look for line with the following content: <code>echo "$Arch is not supported."</code>, (currently line 86).
 +
## Copy the 3 lines above it and paste them just below themselves: at this time it is copy lines 83 to 85 and paste them between lines 85 and 86.
 +
## In the just pasted lines (lines 86-88), replace <code>sparc</code> with <code>armhf</code>, and <code>ppcsparc</code> with <code>ppcarm</code>.
 +
## Look for the first <code>fi</code> just below; copy and paste it below itself (copy line 91 below itself, so line 91 and 92 read the same).
 +
## (For you coders out there, you are adding another <code>if</code> to a nested <code>if</code>, with its corresponding <code>fi</code>.)
 +
## Now save and exit.
 +
# (23) <code>./create_lazarus_deb.sh</code>. This will build the Lazarus IDE Debian package <code>lazarus-project_''[version]''-0_armhf.deb</code>. It will take about 15 minutes.
 +
# (24) Install the FPC source and Lazarus packages: <code>sudo dpkg -i fpc-src_''[version]''_armhf.deb lazarus-project_''[version]''-0_armhf.deb</code>
 +
# (25) Save <code>*.deb</code> to another location, to reinstall later if needed or to share with friends: remember this is free software.
 +
# (26) <code>cd ~; rm -rf ~/pascal ~/tmp</code>
 +
 +
DISCLAIMER: Same disclaimer as in the original article above - if anything, more so!
 +
  
 
[[Category:Install]]
 
[[Category:Install]]
 
[[Category:Linux]]
 
[[Category:Linux]]
 
[[Category:Raspberry Pi]]
 
[[Category:Raspberry Pi]]

Revision as of 12:40, 25 August 2020

English (en) 中文(中国大陆)‎ (zh_CN)

Raspbian Buster (based on Debian 10 Buster) has FPC and Lazarus available in the repositories, but they suffer from the same "design decisions" that don't allow for a nice experience, namely the smooth IDE rebuilding capability based on source packages that is possible with FPC/Lazarus official .deb packages vs the crippled experience with the official Debian/Raspbian packages. One wishes there were official FPC/Lazarus packages for Raspbian as there are for Intel Debian/Ubuntu, which are also frequently updated; not being that the case (at least for now), this page shows the steps for building your own FPC, FPC-source and Lazarus packages for Raspbian. Example shows steps for Lazarus 2.0.6 which includes FPC 3.0.4, most recent at the time of writing. Adjust accordingly.

Requirements:

  • Raspberry Pi 4 Model B, 4 GB (less memory models would require swap), with appropriate cooling (author uses aluminum case that doubles as heatsink) to avoid throttling due to excessive heat
  • Latest Raspbian Buster fully updated

Steps:

  1. Install subversion: sudo apt install subversion
  2. Get bootstrap FPC compiler. The latest compiler is compiled with the previous version of itself.
  3. Extract compiler. This will create a fpc-3.0.2.arm-linux directory. (NOTE: this folder must be on a linux FS [like Documents folder] as FAT doesn't allow the next step to work).
  4. In this directory, as pi user, run ./install.sh
  5. At the four prompts, answer Enter, n, n, n: this is, accept suggested directory /home/pi/fpc-3.0.2, no Textmode IDE, no documentation, no demos. Ignore tar warnings. Note the additional files written to /home/pi: .fpc.cfg, .config/fppkg.cfg, .fppkg/config/default. When the build is done, to delete this temporary bootstrap compiler these files and the /home/pi/fpc-3.0.2 install directory need to be deleted.
  6. Temporarily add FPC install directory to PATH: export PATH=$PATH:$HOME/fpc-3.0.2/bin. If you have to reboot for any reason before completing the FPC build, you have to do this step again.
  7. Test if all ok: fpc abcd. This invokes the just installed compiler trying to compile a non-existent file (abcd). A multiline message will be shown including the compiler version.
  8. Non-step note: the following steps are mostly based on this
  9. Install development libraries: sudo apt install libgtk2.0-dev libgpm-dev libncurses-dev
  10. mkdir ~/pascal
  11. cd ~/pascal
  12. svn co https://svn.freepascal.org/svn/fpc/tags/release_3_0_4 fpc, you have to be online for this and the next step to work.
  13. svn co https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_8 lazarus
  14. cd lazarus/tools/install
  15. Edit create_fpc_deb.sh, look for line with the following content: arm) ppcbin=arm; FPCArch=arm;;, (currently line 109). Copy and paste this line below itself, so it will appear twice. Edit this copy to read like this: armhf) ppcbin=arm; FPCArch=arm;;. Now save the changes and exit.
  16. Run the script: ./create_fpc_deb.sh fpc ~/pascal/fpc/. This will compile the latest compiler with the bootstrap compiler. It takes about 11 minutes. A .deb file will be created: fpc-laz_3.0.4-yymmdd_armhf.deb; the exact name will be shown at the end of the compilation. Rename the file with (NOTE: do not type the brackets): mv [file name shown at end of compilation] fpc-laz_3.0.4_armhf.deb
  17. You have completed the FPC build. Reboot the Pi to get rid of the temporary PATH.
  18. Uninstall the bootstrap FPC: rm -rf ~/.fpc.cfg ~/.config/fppkg.cfg ~/.fppkg ~/fpc-3.0.2 ~/tmp. Check what you just did: fpc abcd should say command is not found.
  19. Install the just created FPC Debian package: sudo dpkg -i ~/pascal/lazarus/tools/install/fpc-laz_3.0.4_armhf.deb. Check if it works: fpc abcd should show the newly installed FPC compiler.
  20. cd ~/pascal/lazarus/tools/install
  21. ./create_fpc_deb.sh fpc-src ~/pascal/fpc/. This builds the FPC source package in about 3 minutes: fpc-src_3.0.4-yymmdd_armhf.deb. Rename with: mv fpc-src_3.0.4-yymmdd_armhf.deb fpc-src_3.0.4_armhf.deb
  22. Edit create_lazarus_deb.sh, look for line with the following content: echo "$Arch is not supported.", (currently line 86). Copy the 3 lines above it and paste them just below themselves: at this time it is copy lines 83 to 85 and paste them between lines 85 and 86. In the just pasted lines (lines 86-88), replace sparc with armhf, and ppcsparc with ppcarm. Look for the first fi just below; copy and paste it below itself (copy line 91 below itself, so line 91 and 92 read the same). For you coders out there, you are adding another if to a nested if, with its corresponding fi. Now save and exit.
  23. ./create_lazarus_deb.sh. This will build the Lazarus IDE Debian package lazarus-project_2.0.8-0_armhf.deb. It will take about 15 minutes.
  24. Install the FPC source and Lazarus packages: sudo dpkg -i fpc-src_3.0.4_armhf.deb lazarus-project_2.0.8-0_armhf.deb
  25. Save *.deb to another location, to reinstall later if needed or to share with friends: remember this is free software.
  26. cd, rm -rf ~/pascal ~/tmp

You can now finally enjoy your fully working, fully up to date Lazarus. Find it in the Programming section of the Raspberry menu. A message titled "Error in EditorMacroScript" will be shown on first run; this also appears in the Raspbian Lazarus, reason still unknown to the original author of this page. Now try to install a package, for example lazreport; it will work!

Want to help the FPC/Lazarus community? Host the resulting .deb packages somewhere on the Internet and drop a note on the forum to let everyone know; rinse and repeat for every release.

DISCLAIMER: these are UNOFFICIAL packages created from modified official sources. DO NOT ASK FOR SUPPORT ANYWHERE, neither on the forums or with the author of this article; use at your own risk.

Upgrading

The following is not written by whoever worked out this process in the first place. It is completely un-authoritative, but it worked for me to upgrade from Laz 2.0.8 to 2.0.10. I make no other claims what-so-ever - Use at your own risk. The bracketed numbers in the steps refer back to the original version (until someone edits it)

Once you have followed the above steps once, you can shortcut the process a little to upgrade. In particular, Steps 1 - 8 should not be necessary, as we have the previous version already installed.

  1. (9) Update development libraries: sudo apt upgrade libgtk2.0-dev libgpm-dev libncurses-dev
  2. (10) if required, mkdir ~/pascal
  3. (11) cd ~/pascal
  4. If you didn't clean out the temp files from last time, do so now: rm -rf fpc lazarus
  5. (12) svn co https://svn.freepascal.org/svn/fpc/tags/[required-release] fpc. (if necessary, browse https://svn.freepascal.org/svn/fpc/tags to find the exact release.)
  6. (13) svn co https://svn.freepascal.org/svn/lazarus/tags/[required-release] lazarus. (if necessary, browse https://svn.freepascal.org/svn/lazarus/tags to find the exact release.)
  7. (14) cd lazarus/tools/install
  8. (15) Edit create_fpc_deb.sh, look for line with the following content: arm) ppcbin=arm; FPCArch=arm;;, (currently line 109).
    1. Copy and paste this line below itself, so it will appear twice.
    2. Edit this copy to read like this: armhf) ppcbin=arm; FPCArch=arm;;. Now save the changes and exit.
  9. (16) Run the script: ./create_fpc_deb.sh fpc ~/pascal/fpc/. This will compile the latest compiler with the bootstrap compiler. It takes about 11 minutes. A .deb file will be created: fpc-laz_[fpc release]-yymmdd_armhf.deb; the exact name will be shown at the end of the compilation.
  10. Rename the file with (NOTE: do not type the brackets): mv [file name shown at end of compilation] fpc-laz_[fpc release]_armhf.deb
  11. (17) You have completed the FPC build. Rebooting the Pi should not be necessary, as we made no temporary PATH. (Yay)
  12. (18) Check/uninstall the bootstrap FPC: rm -rf ~/.fpc.cfg ~/.config/fppkg.cfg ~/.fppkg ~/fpc-[fpc_release] ~/tmp. (If you cleaned up after the initial build, you should only find ~/tmp this time)
  13. Check what you just did: fpc abcd should say command is not found.
  14. (19) Install the just created FPC Debian package: sudo dpkg -i ~/pascal/lazarus/tools/install/fpc-laz_[fpc-release]_armhf.deb. (-i can also upgrade - the message should be "installing [new ver] over [old ver]")
  15. Check if it works: fpc abcd should show the newly installed FPC compiler.
  16. (20) cd ~/pascal/lazarus/tools/install
  17. (21) ./create_fpc_deb.sh fpc-src ~/pascal/fpc/. This builds the FPC source package fpc-src_[fpc-release]-yymmdd_armhf.deb in about 3 minutes.
  18. Rename with: mv fpc-src_[fpc-release]-yymmdd_armhf.deb fpc-src_[fpc-release]_armhf.deb
  19. (22) Edit create_lazarus_deb.sh,
    1. Look for line with the following content: echo "$Arch is not supported.", (currently line 86).
    2. Copy the 3 lines above it and paste them just below themselves: at this time it is copy lines 83 to 85 and paste them between lines 85 and 86.
    3. In the just pasted lines (lines 86-88), replace sparc with armhf, and ppcsparc with ppcarm.
    4. Look for the first fi just below; copy and paste it below itself (copy line 91 below itself, so line 91 and 92 read the same).
    5. (For you coders out there, you are adding another if to a nested if, with its corresponding fi.)
    6. Now save and exit.
  20. (23) ./create_lazarus_deb.sh. This will build the Lazarus IDE Debian package lazarus-project_[version]-0_armhf.deb. It will take about 15 minutes.
  21. (24) Install the FPC source and Lazarus packages: sudo dpkg -i fpc-src_[version]_armhf.deb lazarus-project_[version]-0_armhf.deb
  22. (25) Save *.deb to another location, to reinstall later if needed or to share with friends: remember this is free software.
  23. (26) cd ~; rm -rf ~/pascal ~/tmp

DISCLAIMER: Same disclaimer as in the original article above - if anything, more so!