Recent

Author Topic: Trouble compiling Lazarus  (Read 11671 times)

hansotten

  • Jr. Member
  • **
  • Posts: 88
Trouble compiling Lazarus
« on: July 06, 2016, 04:20:14 pm »
A half year ago I succeeded in building Freepascal and Lazarus on my Raspberry Pi. With ARMHF support.

With a new Raspberry 3 and new versions I tried to replicate that. After some strugling (the seed compiler now required is 3.0 for whch no binaries are available, but I found a minimal compiler on getlazarus.org and that was sufficient to bootstrap Freepascal.

What I did was

install the minimal compiler from getlazarus.org
get http://svn.freepascal.org/svn/fpc/tags/release_3_0_0_rc2/ into temporary directory
make all OPT=-dFPC_ARMHF
make install OPT=-dFPC_ARMHF PREFIX=/usr/local
make install sourceinstall OPT=-dFPC_ARMHF PREFIX=/usr/local

rm -f "/usr/local/bin/ppcarm"
ln -sf "/usr/local/lib/fpc/3.0.0/ppcarm" "/usr/local/bin/ppcarm"

Recreated fpc.fg with
/usr/local/bin/fpcmkcfg -d basepath=/usr/local/lib/fpc/3.0.0 -o /usr/local/bin/fpc.cfg

Now Freepascal compiler runs fine, I have 3.0.0rc2. Simple command line program 'Hello world' works.

But Lazarus refuses to build.

My recipe is:

install dependencies
apt-get install -y libgtk2.0-dev libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev libatk1.0-dev libghc-x11-dev
apt-get install -y libx11-dev libgdk-pixbuf2.0-dev libcairo2-dev gir1.2-coglpango-1.0 libpangox-1.0-dev xorg-dev libgtk2.0-dev libpango1.0-dev
Get the source from http://svn.freepascal.org/svn/lazarus/tags/lazarus_1_6_RC2 into temporary directory
make all OPT=-dFPC_ARMHF

Next would be:

make install OPT=-dFPC_ARMHF PREFIX=/usr/local
 

But make all fails immediately with as output:

make -C packager/registration
make[1]: Entering directory '/usr/local/lazarus/lazarus_1_6_RC2/packager/registration'
/bin/rm -f ../units/arm-linux/fcllaz.ppu
/usr/local/bin/ppcarm -MObjFPC -Scghi -O1 -g -gl -l -vewnhibq -Fu. -Fu/usr/local/lib/fpc/3.0.0/units/arm-linux/rtl -FE. -FU../units/arm-linux -darm fcllaz.pas
Free Pascal Compiler version 3.0.0rc2 [2016/07/06] for arm
Copyright (c) 1993-2015 by Florian Klaempfl and others
(1002) Target OS: Linux for ARMHF
(3104) Compiling fcllaz.pas
(3104) Compiling registerfcl.pas
/usr/local/lazarus/lazarus_1_6_RC2/packager/registration/registerfcl.pas(45,22) Fatal: (10022) Can't find unit process used by RegisterFCL
Fatal: (1018) Compilation aborted
Makefile:2702: recipe for target 'fcllaz.ppu' failed
make[1]: *** [fcllaz.ppu] Error 1
make[1]: Leaving directory '/usr/local/lazarus/lazarus_1_6_RC2/packager/registration'
Makefile:3050: recipe for target 'registration' failed
make: *** [registration] Error 2

I suppose I need to inform somehow about  the whereabouts of units like 'process', but my knowledge and skills fail to see where and how?

I did find unit process in /usr/local/lib/fpc/3.0.0/units/arm-linux/fcl-process/process.ppu

In FPC.CFG I have

# searchpath for units and other system dependent things
-Fu/usr/local/lib/fpc/3.0.0/units/$fpctarget
-Fu/usr/local/lib/fpc/3.0.0/units/$fpctarget/*
-Fu/usr/local/lib/fpc/3.0.0/units/$fpctarget/rtl

 Now if fpctarget = arm-linux ?
 
« Last Edit: July 06, 2016, 04:34:57 pm by hansotten »

Thaddy

  • Hero Member
  • *****
  • Posts: 14214
  • Probably until I exterminate Putin.
Re: Trouble compiling Lazarus
« Reply #1 on: July 06, 2016, 04:31:45 pm »
Hans, what is RC2 mean? You are a year behind.
Anyway. As an experiment all my posts today where from a RPi3 and all code provided running under trunk.
So plz be more specific?
Specialize a type, not a var.

hansotten

  • Jr. Member
  • **
  • Posts: 88
Re: Trouble compiling Lazarus
« Reply #2 on: July 06, 2016, 05:10:23 pm »
Hi Thaddy,

Just tried trunk for Freepascal (now have 3.1.1 running fine) and Lazarus. Same process, same results

Still the same error building Lazarus ..
« Last Edit: July 06, 2016, 05:26:34 pm by hansotten »

abtaylr

  • Full Member
  • ***
  • Posts: 107
Re: Trouble compiling Lazarus
« Reply #3 on: July 06, 2016, 06:33:12 pm »
Here's a link with instructions that will probably fix your problem:

http://wiki.freepascal.org/Lazarus_Can%27t_find_unit_system_used_by_fcllaz

abtaylr

  • Full Member
  • ***
  • Posts: 107
Re: Trouble compiling Lazarus
« Reply #4 on: July 06, 2016, 07:01:38 pm »
When you changed from fpc-3.0.0RC2 over to fpc-3.1.1 did you update your .fpc.cfg file to reflect the location of the lib files--e.g. /usr/local/lib/fpc/3.1.1/?

hansotten

  • Jr. Member
  • **
  • Posts: 88
Re: Trouble compiling Lazarus
« Reply #5 on: July 06, 2016, 07:14:59 pm »
Yes,

I used a new image of Raspbian.


abtaylr

  • Full Member
  • ***
  • Posts: 107
Re: Trouble compiling Lazarus
« Reply #6 on: July 06, 2016, 07:17:57 pm »
Have you run 'fppkg list' and 'fppkg listsettings' yet?  When you have let me know how they came out.

abtaylr

  • Full Member
  • ***
  • Posts: 107
Re: Trouble compiling Lazarus
« Reply #7 on: July 06, 2016, 07:27:07 pm »
Another thing to check with the fpc.cfg files is to also look in your /fpc/bin directory to see if there is an additional fpc.cfg file in that location.  You want fpc to only be looking for 1 fpc.cfg file not 2. The one in the /home/username directory is best.

hansotten

  • Jr. Member
  • **
  • Posts: 88
Re: Trouble compiling Lazarus
« Reply #8 on: July 06, 2016, 07:36:25 pm »
Hi,

Thanks for the suggestions! It must be indeed a reference in one the configuration files.

I will continue (tomorrow) with the challenge of telling the build procedure where the units are!

Hans

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Trouble compiling Lazarus
« Reply #9 on: July 07, 2016, 05:17:50 pm »
For your information... I also got the "process not found". It seemed something was wrong with the generated fpc.cfg. I now just use the samplecfg to generate a default one in /etc. That seems to work.

Here are my complete steps to install FPC trunk and Lazarus trunk on a clean 2016-05-27-raspbian-jessie.img image.
(you see I also need to call "make all" twice for Lazarus because of a fpcres error. I'm not sure why that is yet.)

Code: [Select]
# ======================================================
# Based on clean 2016-05-27-raspbian-jessie.img
# ======================================================

# ======================================================
# First some essentials
# ======================================================
sudo -i
apt-get update
apt-get upgrade
apt-get dist-upgrade
# apt-get remove lazarus
# apt-get remove fpc
# apt-get remove fp-compiler
apt-get autoremove
apt-get clean
reboot
 
# ======================================================
# install remote descktop serveer for rdp session win10
# only neede is headless RPI
# ======================================================
# https://www.maketecheasier.com/enabling-remote-desktop-access-on-raspberry-pi/
sudo apt-get install xrdp
sudo nano /etc/xrdp/xrdp.ini
# bitmap_compression: no
 
# ======================================================
# some other essentials
# ======================================================
sudo apt-get install build-essential p7zip-full subversion
sudo apt-get install libx11-dev libgdk-pixbuf2.0-dev libcairo2-dev lpango-1.0 libpangox-1.0-dev xorg-dev libatk1.0-dev libgtk2.0-dev

# ======================================================
# Install FPC and Lazarus trunk
# ======================================================
sudo -i

# ------------------------------------------------------
# First FPC
# ------------------------------------------------------
mkdir /usr/local/fpc
cd /usr/local/fpc

# ------------------------------------------------------
# We need a bootstrap compiler fpc 3.0.0
# There is NONE AVAILABLE so we need to download complete
# fpc-3.0.0.arm-linux-raspberry1wq.tar
# ------------------------------------------------------
wget ftp://ftp.freepascal.org/pub/fpc/dist/3.0.0/arm-linux/fpc-3.0.0.arm-linux-raspberry1wq.tar
tar xvf fpc-3.0.0.arm-linux-raspberry1wq.tar
cd fpc-3.0.0.arm-linux
tar xvf binary.arm-linux.tar
tar zxvf base.arm-linux.tar.gz
cd ..

# ------------------------------------------------------
# checkout fpc trunk
# ------------------------------------------------------
svn co http://svn.freepascal.org/svn/fpc/trunk trunk
svn export --force trunk trunktmp
cd trunktmp

# ------------------------------------------------------
# compile fpc trunk
# ------------------------------------------------------
make all OPT="-dFPC_ARMHF" PP=/usr/local/fpc/fpc-3.0.0.arm-linux/lib/fpc/3.0.0/ppcarm
make install OPT="-dFPC_ARMHF" PREFIX=/usr/local PP=/usr/local/fpc/trunktmp/compiler/ppcarm
rm /usr/local/bin/ppcarm
rm /usr/local/bin/sameplecfg
ln -sf /usr/local/lib/fpc/3.1.1/ppcarm /usr/local/bin/ppcarm
ln -sf /usr/local/lib/fpc/3.1.1/samplecfg /usr/local/bin/samplecfg
make install sourceinstall OPT="-dFPC_ARMHF" PREFIX=/usr/local
rm /usr/share/fpcsrc
ln -sf /usr/local/share/src/fpc-3.1.1/fpc /usr/share/fpcsrc

# /usr/local/bin/fpcmkcfg -d basepath=/usr/local/lib/fpc/3.1.1 -o /usr/local/bin/fpc.cfg
# this doesn't seem to work correctly ???

samplecfg /usr/local/lib/fpc/3.1.1 /etc
# Running on linux
# Write permission in /etc.
# Writing sample configuration file to /etc/fpc.cfg
# Writing sample configuration file to /usr/local/lib/fpc/3.1.1/ide/text/fp.cfg
# Writing sample configuration file to /usr/local/lib/fpc/3.1.1/ide/text/fp.ini
# Writing sample configuration file to /etc/fppkg.cfg
# Writing sample configuration file to /etc/fppkg/default

# ------------------------------------------------------
# Then Lazarus
# ------------------------------------------------------
mkdir /usr/local/lazarus
cd /usr/local/lazarus

# ------------------------------------------------------
# checkout fpc trunk
# ------------------------------------------------------
svn co http://svn.freepascal.org/svn/lazarus/trunk trunk
svn export --force trunk trunktmp
cd trunktmp
make all OPT="-dFPC_ARMHF"

# Can't call the resource compiler "/usr/local/bin/fpcres", switching to external mode
# calling make all twice does work ????????
make all OPT="-dFPC_ARMHF"

make install OPT="-dFPC_ARMHF" PREFIX=/usr/local

# ------------------------------------------------------
# connect on Windows via Remote Desktop Connecton (mstsc.exe)
# user pi password rapberry
# Start > Run > lazarus-ide
# choose start-ide and create small test-project and run
# ------------------------------------------------------

Comments are welcome. (I also have limited experience with FPC/Lazarus on Linux-like systems)

I also needed to use the standard FPC-install 3.0.0 because there is no bootstrap FPC compiler 3.0.0.

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Trouble compiling Lazarus
« Reply #10 on: July 08, 2016, 11:12:39 am »
Ok, I found the problem with needing to compile Lazarus twice. From another topic where the fpcres-error kept coming, I found out I skipped a step: Increasing the standard swapsize from 100 to 512 MB.

Here are the new steps to install FPC & Lazarus trunk on a complete clean 2016-05-27-raspbian-jessie.img RPI3:

Code: [Select]
# ======================================================
# Based on clean 2016-05-27-raspbian-jessie.img
# Total install time: 38 minutes (from complete scratch)
# by rvk (v.1.1, 2016-07-08)
# ======================================================

# ======================================================
# first some essentials (5.5 minutes)
# ======================================================
sudo -i
apt-get update
apt-get upgrade -y
apt-get autoremove
apt-get autoclean
reboot
 
# ======================================================
# install remote descktop serveer for rdp session win10
# only neede is headless RPI (1 minute)
# ======================================================
# https://www.maketecheasier.com/enabling-remote-desktop-access-on-raspberry-pi/
sudo apt-get -y install xrdp
sudo nano /etc/xrdp/xrdp.ini
bitmap_compression: no   # <-- change this line
 
# ======================================================
# some other essentials (2 minutes)
# ======================================================
sudo apt-get -y install build-essential p7zip-full subversion
sudo apt-get -y install libx11-dev libgdk-pixbuf2.0-dev libcairo2-dev lpango-1.0 libpangox-1.0-dev xorg-dev libatk1.0-dev libgtk2.0-dev

# ======================================================
# we NEED to extend the swapfile (1 minute)
# ======================================================
sudo nano /etc/dphys-swapfile
CONF_SWAPSIZE=512   # <-- change this line
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start

# ======================================================
# if you're not on raspbian-jessie this could work too
# ======================================================
# dd if=/dev/zero of=/path/to/swapfile bs=1M count=512 # For 512MB swap file
# mkswap /path/to/swapfile
# swapon /path/to/swapfile

# ======================================================
# install fpc and lazarus trunk (total 28.5 minutes)
# ======================================================
sudo -i

# ------------------------------------------------------
# first fpc
# ------------------------------------------------------
mkdir /usr/local/fpc
cd /usr/local/fpc

# ------------------------------------------------------
# We need a bootstrap compiler fpc 3.0.0 (2.5 minutes)
# There is NONE AVAILABLE so we need to download complete
# fpc-3.0.0.arm-linux-raspberry1wq.tar
# ------------------------------------------------------
wget ftp://ftp.freepascal.org/pub/fpc/dist/3.0.0/arm-linux/fpc-3.0.0.arm-linux-raspberry1wq.tar
tar xvf fpc-3.0.0.arm-linux-raspberry1wq.tar
cd fpc-3.0.0.arm-linux
tar xvf binary.arm-linux.tar
tar zxvf base.arm-linux.tar.gz
cd ..

# ------------------------------------------------------
# checkout fpc trunk (3 minutes)
# ------------------------------------------------------
svn co http://svn.freepascal.org/svn/fpc/trunk trunk
svn export --force trunk trunktmp
cd trunktmp

# ------------------------------------------------------
# compile fpc trunk (11 minutes)
# ------------------------------------------------------
make all OPT="-dFPC_ARMHF" PP=/usr/local/fpc/fpc-3.0.0.arm-linux/lib/fpc/3.0.0/ppcarm

# ------------------------------------------------------
# install fpc trunk (2 minutes)
# ------------------------------------------------------
make install OPT="-dFPC_ARMHF" PREFIX=/usr/local PP=/usr/local/fpc/trunktmp/compiler/ppcarm
rm /usr/local/bin/ppcarm
rm /usr/local/bin/sameplecfg
ln -sf /usr/local/lib/fpc/3.1.1/ppcarm /usr/local/bin/ppcarm
ln -sf /usr/local/lib/fpc/3.1.1/samplecfg /usr/local/bin/samplecfg
make install sourceinstall OPT="-dFPC_ARMHF" PREFIX=/usr/local
rm /usr/share/fpcsrc
ln -sf /usr/local/share/src/fpc-3.1.1/fpc /usr/share/fpcsrc

# /usr/local/bin/fpcmkcfg -d basepath=/usr/local/lib/fpc/3.1.1 -o /usr/local/bin/fpc.cfg
# this doesn't seem to work correctly ???

samplecfg /usr/local/lib/fpc/3.1.1 /etc
# Running on linux
# Write permission in /etc.
# Writing sample configuration file to /etc/fpc.cfg
# Writing sample configuration file to /usr/local/lib/fpc/3.1.1/ide/text/fp.cfg
# Writing sample configuration file to /usr/local/lib/fpc/3.1.1/ide/text/fp.ini
# Writing sample configuration file to /etc/fppkg.cfg
# Writing sample configuration file to /etc/fppkg/default

# ------------------------------------------------------
# then Lazarus
# ------------------------------------------------------
mkdir /usr/local/lazarus
cd /usr/local/lazarus

# ------------------------------------------------------
# checkout lazarus trunk (1.5 minutes)
# ------------------------------------------------------
svn co http://svn.freepascal.org/svn/lazarus/trunk trunk
svn export --force trunk trunktmp
cd trunktmp

# ------------------------------------------------------
# compile lazarus trunk  (6.5 minutes)
# ------------------------------------------------------
make all OPT="-dFPC_ARMHF"

# ------------------------------------------------------
# install lazarus trunk  (2 minutes)
# ------------------------------------------------------
make install OPT="-dFPC_ARMHF" PREFIX=/usr/local

# ------------------------------------------------------
# remove menu-cache to make Lazarus visible in menu
# ------------------------------------------------------
exit  # from sudo
killall lxpanel
find ~/.cache/menus -name '*' -type f -print0 | xargs -0 rm
exit  # from pi

# ------------------------------------------------------
# connect on Windows via Remote Desktop Connecton (mstsc.exe)
# user pi password rapberry
# Menu > Programming > Lazarus
# create small test-project and run
# ------------------------------------------------------

# ======================================================
# note: recompiling lazarus as use pi
# will create a working copy under ~/.lazarus/bin
# ======================================================

hansotten

  • Jr. Member
  • **
  • Posts: 88
Re: Trouble compiling Lazarus
« Reply #11 on: July 08, 2016, 12:06:54 pm »
Thanks to all!

The steps of rvk are what I have too. Increase swapfile indeed is helping, I read, and so I use a size of 1000MB. And I change the memory split to 16 MB just to give as much as poosible space.  A large SD card with enough free space also may help.

I found out yesterday where my error came from: an error in the path supplied to the making of fpc.cfg.

Now I have trunk of FPC (3.1.1) and Lazarus (1.7) working fine. In a subdir of user pi, so its easy to move to another installation too.

It was an interesting (re)learning of bash, linux and the operational aspects  fpc and Lazarus.

My personal notebook of the steps I performed is here: http://duinorasp.hansotten.com/freepascal-and-lazarus-installation-on-rpi/
« Last Edit: July 08, 2016, 12:11:22 pm by hansotten »

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Trouble compiling Lazarus
« Reply #12 on: July 08, 2016, 12:47:13 pm »
I found out yesterday where my error came from: an error in the path supplied to the making of fpc.cfg.

Now I have trunk of FPC (3.1.1) and Lazarus (1.7) working fine. In a subdir of user pi, so its easy to move to another installation too.
Yes, in time I will also change my instruction to a user-install instead of a root-install.

In your instruction there are some libraries installed (on the second line) which are already installed on the first line :)
libgdk-pixbuf2.0-dev, libcairo2-dev, libgtk2.0-dev & libpango1.0-dev

Getting the fpc-3.0.0.raspberry-min.tar.gz from getlazarus is a nice touch. I wished FPC had a current small bootstrap compiler so everything could get downloaded from the original site.

I also didn't have the fix for the path to the gcclib yet (thanks).
But in your instruction you said to change it in /etc/fpc.cfg while somewhere else the /home/pi/fpc-3/1/bin/fpc.cfg and ~/.fpc.cfg are used ??? (.fpc.cfg ?)
You did later state "Copy the fpc.cfg also to /pi/home.fpc.cfg to be sure" but that will override your previous one created. (home.fpc.cfg ?)

There are lots of instructions to be found on the internet but all have some small discrepancies (due to changes in underlying OS, typos or changes made in the procedures). That's why I tried to give complete instructions (with exact commandline commands).

hansotten

  • Jr. Member
  • **
  • Posts: 88
Re: Trouble compiling Lazarus
« Reply #13 on: July 08, 2016, 02:01:22 pm »
Oeps, /etc/fpc.cfg is an error, leftover from the past ;)

I have .fpc.cfg in the home dir, because Lazarus did not pick it up the first time from the bin directory.  Perhaps not necessary now.

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Trouble compiling Lazarus
« Reply #14 on: July 08, 2016, 02:07:28 pm »
I have .fpc.cfg in the home dir, because Lazarus did not pick it up the first time from the bin directory.  Perhaps not necessary now.
Maybe that was also the trouble for me... and that I needed to use samplecfg to create one in /etc/fpc.cfg.
Next time I adjust the script I will investigate why that is.

 

TinyPortal © 2005-2018