Recent

Author Topic: Setting up cross compiler from linux-64 to linux-32,  (Read 1473 times)

Prime

  • Jr. Member
  • **
  • Posts: 62
Setting up cross compiler from linux-64 to linux-32,
« on: April 16, 2023, 06:43:48 pm »
Hi all,

Lazarus x64-linux, 2.2.6, fpc 3.2.2. and in case it's significant I have Abbrevia, CEF4Delphi, DCPcrypt, Indy10 and ZeosDBO installed from the online package manager.

OS : OpenSUSE tumbleweed.

Lazarus & FPC where installed from the official rpms on sourceforge rather than the ones supplied by suse.

I've been following the following page https://wiki.freepascal.org/Cross_compiling and have successfully managed to build the fpc
cross compiler which compiles and builds the test program :
Code: Pascal  [Select][+][-]
  1. program test;
  2. begin
  3.   writeln('DATE ',{$i %DATE%});
  4.   writeln('FPCTARGET ',{$i %FPCTARGET%});
  5.   writeln('FPCTARGETCPU ',{$i %FPCTARGETCPU%});
  6.   writeln('FPCTARGETOS ',{$i %FPCTARGETOS%});
  7.   writeln('FPCVERSION ',{$i %FPCVERSION%});
  8. end.
  9.  

This produces the following output....

Quote
DATE 2023/04/16
FPCTARGET i386
FPCTARGETCPU i386
FPCTARGETOS Linux
FPCVERSION 3.2.2

So I then fire up the lazarus-ide and load up my current project, head into project options->config and target and set the Target CPU family to i386 and click ok.

The problem is that when I click Run->Build the build stops almost immediately with :

Quote
Hint: (11030) Start of reading config file /etc/fpc.cfg
Hint: (11031) End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 3.2.2 [2023/04/16] for i386
Copyright (c) 1993-2021 by Florian Klaempfl and others
(1002) Target OS: Linux for i386
(3104) Compiling fcllaz.pas
/usr/lib64/lazarus/packager/registration/fcllaz.pas(11,3) Fatal: (10022) Can't find unit db used by fcllaz
Fatal: (1018) Compilation aborted
Error: /usr/bin/ppcross386 returned an error exitcode

Any idea what the problem is?

I also tried manually compiling the LCL with "configure build lazarus" setting target os & target cpu to linux & i386, but that fails in the same way.

Cheers.

Phill.
« Last Edit: April 16, 2023, 06:51:33 pm by Prime »

PeterBB

  • New Member
  • *
  • Posts: 40
Re: Setting up cross compiler from linux-64 to linux-32,
« Reply #1 on: April 16, 2023, 10:00:48 pm »
As a pure guess....

Probably need to compile the RTL for 32bit
and/or
make sure the fpc.cfg is pointing to these 32 bit libraries.

Maybe do a recursive grep for db.o in /usr/lib to see what you have got there?

Prime

  • Jr. Member
  • **
  • Posts: 62
Re: Setting up cross compiler from linux-64 to linux-32,
« Reply #2 on: May 07, 2023, 09:34:33 pm »
Right with the aid of : https://forum.lazarus.freepascal.org/index.php/topic,55324.15.html

I've been able to progress a little further.

I needed to add some  lines to fpc.cfg to tell the compiler where to find the gcc libs and where to find the units, if the target CPU was i386 :

Code: Pascal  [Select][+][-]
  1. #ifdef cpui386
  2. -Fl/usr/lib/gcc/x86_64-linux-gnu/13/32
  3. -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
  4. #endif
  5.  

Now the problem I am having is with fpc finding various libraries, I've been installing the 32bit versions of the needed libraries, which are installed in /usr/lib. However fpc doesn't seem to be able to find them, the SuSE packages install the following (for example libgtk) :

Code: [Select]
lrwxrwxrwx 1 root root      27 Mar 20 01:11 libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.2400.33
-rwxr-xr-x 1 root root 5323004 Mar 20 01:11 libgtk-x11-2.0.so.0.2400.33

Note no libgtk-x11-2.0.so. If I manually add a link with ln -s libgtk-x11-2.0.so.0.2400.33 libgtk-x11-2.0.so

The fpc finds it without problems.

I'll also post on the SuSE forum and see if this is expected behavior, if so is there a way of looking for the lib*.so.0 files for linking, as this seems to be what SuSe is creating by default?

Cheers.

Phill.

TRon

  • Hero Member
  • *****
  • Posts: 2515
Re: Setting up cross compiler from linux-64 to linux-32,
« Reply #3 on: May 07, 2023, 11:46:39 pm »
@Prime:
Where exactly is (or should be) your 32 bit version of libgtk located ?

Prime

  • Jr. Member
  • **
  • Posts: 62
Re: Setting up cross compiler from linux-64 to linux-32,
« Reply #4 on: May 07, 2023, 11:50:33 pm »
@Prime:
Where exactly is (or should be) your 32 bit version of libgtk located ?

/usr/lib

That's what I'm saying the SuSE RPM only installs /usr/lib/libgtk-x11-2.0.so.0.2400.33, which is the real library file and /usr/lib/libgtk-x11-2.0.so.0, which is a softlink to it.

Cheers.

Phill.

TRon

  • Hero Member
  • *****
  • Posts: 2515
Re: Setting up cross compiler from linux-64 to linux-32,
« Reply #5 on: May 07, 2023, 11:52:12 pm »
That's what I'm saying the SuSE RPM only installs /usr/lib/libgtk-x11-2.0.so.0.2400.33, which is the real library file and /usr/lib/libgtk-x11-2.0.so.0, which is a softlink to it.
Well, on a 64 bit system that would be your 64 bit version of the library , not the 32 bit one. Does SuSe use multiarch ?

edit: ah., ok. I just read that suse uses lib dir for 32 bit libs and lib64 dir for 64 bit versions. Confusing as hell for me  :)

link that explained that for me: https://www.pilotlogic.com/sitejoom/index.php/100-wiki/technical/multiarch/398-multiarch-on-linux.html
« Last Edit: May 08, 2023, 12:00:42 am by TRon »

Prime

  • Jr. Member
  • **
  • Posts: 62
Re: Setting up cross compiler from linux-64 to linux-32,
« Reply #6 on: May 08, 2023, 12:01:00 am »
That's what I'm saying the SuSE RPM only installs /usr/lib/libgtk-x11-2.0.so.0.2400.33, which is the real library file and /usr/lib/libgtk-x11-2.0.so.0, which is a softlink to it.
Well, on a 64 bit system that would be your 64 bit version of the library , not the 32 bit one. Does SuSe use multiarch ?

edit: ah., ok. I just read that suse uses lib dir for 32 bit libs and lib64 dir for 64 bit versions. Confusing as hell for me  :)

link that explained that for me: https://www.pilotlogic.com/sitejoom/index.php/100-wiki/technical/multiarch/398-multiarch-on-linux.html

Yep can deffo confirm that by looking at the file list in YaST, 32 bit libs are in /usr/lib, 64 bit in /usr/lib64.

Cheers.

Phill.

TRon

  • Hero Member
  • *****
  • Posts: 2515
Re: Setting up cross compiler from linux-64 to linux-32,
« Reply #7 on: May 08, 2023, 12:09:53 am »
@Prime:
Normally (I do not know about SuSe but assume it is the same) you would install the dev package of/for the library.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Setting up cross compiler from linux-64 to linux-32,
« Reply #8 on: May 08, 2023, 10:57:23 am »

Note no libgtk-x11-2.0.so. If I manually add a link with ln -s libgtk-x11-2.0.so.0.2400.33 libgtk-x11-2.0.so

The fpc finds it without problems.

I'll also post on the SuSE forum and see if this is expected behavior, if so is there a way of looking for the lib*.so.0 files for linking, as this seems to be what SuSe is creating by default?

I haven't used SUSE in a decade, but in the past installing the corresponding -dev or -devel package that contained the header files for the lib and the symlink fixed that.

 

TinyPortal © 2005-2018