Building from Source

From Ultibo.org
Jump to: navigation, search

Building the Ultibo RTL


Ultibo core is actively being developed with new features and bug fixes added regularly. New releases of the installer download will be made available regularly but not as frequently as changes to the Ultibo core source itself, being open source also means that you have the opportunity to modify the source and experiment with ideas and changes (you might even choose to contribute some of those changes).

To take advantage of fixes and enhancements in the Ultibo core source without waiting for a new release of the installer you will need to rebuild the Ultibo run time library (RTL).

The latest version of the Ultibo core source is always available on GitHub in the Ultibo Core repository and can be downloaded as a zip file, or if you are comfortable with using git you can clone your own copy of it.

The folder structure of the repository is exactly the same as what is used by the Ultibo core installation so you can simply unzip the downloaded file and copy it over the top of what was installed. The repository starts at the source folder, if you look at your installation you will find the same folder at C:\Ultibo\Core\fpc\3.1.1 so all you need to do is copy the contents of the zip to this folder and it will overwrite the current version with the new one.


To make the process of building the RTL as quick and easy as possible we have included a tool to take care of the process for you, in Lazarus go to Build Ultibo RTL ... in the Tools menu to start the Ultibo RTL Builder tool.

BuildFromSource-BuildRTL.png


You can choose to build either the ARMv6 or ARMv7 versions of the RTL or both, simply click the Build button to start the process.

BuildFromSource-RTLBuilder.png


When the build process has completed you will see a message at the bottom of the RTL Builder window indicating the result, if errors are shown check the message for more information.

BuildFromSource-RTLBuilder-Completed.png


After completing the process, all applications compiled in Lazarus will use the latest version of the RTL and include any new features or fixes provided.

Note: It may be best to restart Lazarus after rebuilding the RTL to ensure it uses only the latest versions

Building Free Pascal


The version of Free Pascal (FPC) included with Ultibo core has been modified to add the Ultibo target (-Tultibo) and to enable linking of the executable produced into a form that is suitable for use on Raspberry Pi. The complete source of the modified FPC can be found on GitHub in the Ultibo FPC repository and can be downloaded (zip or clone) and overlayed onto the Ultibo core installation to allow rebuilding of FPC.

These instructions only relate to building the ARM cross compiler and use the native compiler installed with Ultibo core to perform the build, you can find instructions in the Free Pascal Wiki for building a native compiler for your platform if required.

Once you have the sources installed, open a command prompt and change to the directory where the FPC sources for Ultibo core are installed:

cd C:\Ultibo\Core\fpc\3.1.1\source

Set the path to include the Free Pascal compiler version used by Ultibo core:

set path=C:\Ultibo\Core\fpc\3.1.1\bin\i386-Win32

Delete any instances of fpmake.exe otherwise make will fail with an error (they will be recreated as part of the build):

del fpmake.exe /s

Do a make distclean to remove files leftover after previous builds:

make distclean OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" FPC=C:/Ultibo/Core/fpc/3.1.1/bin/i386-win32/ppc386.exe

Check for any errors and run make all to build the compiler, rtl and packages:

make all OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" FPC=C:/Ultibo/Core/fpc/3.1.1/bin/i386-win32/ppc386.exe

If that was successful, run make crossinstall to install the new cross compiler, rtl and packages

make crossinstall BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a FPC=C:/Ultibo/Core/fpc/3.1.1/bin/i386-win32/ppc386.exe INSTALL_BASEDIR=C:/Ultibo/Core/fpc/3.1.1

The cross install will place all of the rtl and package files in the folder C:\Ultibo\Core\fpc\3.1.1\units\arm-ultibo but since these build instructions specify ARMV7A they will not be usable for Raspberry Pi A, B, A+, B+ and Zero. To resolve this delete the entire arm-ultibo folder in C:\Ultibo\Core\fpc\3.1.1\units and follow the instructions above to rebuild the Ultibo RTL for both ARMv6 and ARMv7.

Building Lazarus


Building or rebuilding Lazarus follows almost exactly the instructions provided with the official sources. The changes made to Lazarus for the Ultibo edition relate mostly to adding and removing menu items and options that are not relevant to embedded development, some of the makefiles have also been modified to remove components and reduce the size of what is distributed.

You will need to add the modified Lazarus sources to your installation before you can build Lazarus, these can be downloaded from the Ultibo Lazarus repository on GitHub. Either download the zip or clone the repository depending on your preference and then overlay the downloaded sources onto your Ultibo core installation.

Once you have the sources installed, open a command prompt and change to the directory where Ultibo core is installed:

cd C:\Ultibo\Core

Set the path to include the Free Pascal compiler version used by Ultibo core:

set path=C:\Ultibo\Core\fpc\3.1.1\bin\i386-Win32

Use make to build Lazarus and all the required components:

make clean all

Make will report any errors, otherwise once the build is completed the newly compiled version of Lazarus will be ready to use.

Additional Information


The information on this page is specific to building FPC and Lazarus on Windows but should be able to be modified to suit other platforms such as Linux or Mac OS X. The links below provide more detailed information on building and installing FPC and Lazarus for users with advanced requirements.

  • Building Lazarus - Detailed information and examples for building and installing Lazarus and FPC on a variety of platforms.
  • Build FAQ - The official Free Pascal build FAQ with full details on how to build FPC for many platforms.
  • Cross Compiling - A guide to building FPC cross compilers for multiple platform combinations.