Recent

Author Topic: [SOLVED] Linux/Ubuntu: how to compile 32 bit programs on a 64 bit Lazarus?  (Read 13063 times)

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #15 on: August 27, 2018, 10:26:25 pm »
[...] I found "fpc-source" (which is not installed) and "fpc-source-3.0.4" (which is installed).

Yeah, sorry, fpc-source-3.0.4 is the one. Mine is called fpc-src because I install from a local repository. As for fpc-source, it's simply a dependency package to pull in the latest version; you can ignore it since lazarus-project picks its own proper dependencies anyway.

The idea, as you may have gleaned, is to induce a full re-install of your current source package to see whether the culprit is the package itself or some other thing.

@lucamar: Thank you too for helping me.

Well, that's what the fora are for, usually. :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Hartmut

  • Hero Member
  • *****
  • Posts: 742
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #16 on: August 27, 2018, 11:08:26 pm »
Via Synaptic I "uninstalled completely" fpc-source-3.0.4
Via Terminal I deinstalled Lazarus 1.8.2 via "sudo apt-get purge lazarus"
Via Terminal I installed Lazarus again via "sudo apt-get install lazarus"
Package "libc6-dev-i386" from step 1 was already installed.
The 2 files from steps 2..5 already existed.
The one and only file in folder "/usr/share/fpcsrc/3.0.4/" was the "Makefile" from Handoko's reply #10.
I repeated steps 6 and 7. The translated error message (see screenshot) is now:

/bin/rm -f build-stamp.*
/bin/rm -f base.build-stamp.*
make compiler_cycle RELEASE=1
make[1]: Folder „/usr/share/fpcsrc/3.0.4“ is entered
make -C compiler cycle
make[2]: Folder „/usr/share/fpcsrc/3.0.4“ is entered
make[2]: *** compiler: File or folder not found. Finish.
make[2]: Folder „/usr/share/fpcsrc/3.0.4“ is left
Makefile:2780: recipe for target 'compiler_cycle' failed
make[1]: *** [compiler_cycle] Error 2
make[1]: Folder „/usr/share/fpcsrc/3.0.4“ is left
Makefile:2812: recipe for target 'build-stamp.i386-linux' failed
make: *** [build-stamp.i386-linux] Error 2

What can I do?

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #17 on: August 27, 2018, 11:26:30 pm »
I declare myself routed: I don't know what else you can do, short of taking "desperate" measures---i.e. installing everything by hand after a thorough clean-up and double-checking each step.

I'm sorry.  :'(
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #18 on: August 27, 2018, 11:31:30 pm »
ETA

Via Synaptic I "uninstalled [...]
Via Terminal I deinstalled [...]
Via Terminal I installed [...]

You do realize that you could have done all that with either Synaptic or via terminal, don't you? No need to change for each step: just use the tool you want.

ETAA: Sorry about the double-posting; don't know how it happened---I *did* click "modify", not "reply"!
« Last Edit: August 27, 2018, 11:38:41 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #19 on: August 28, 2018, 05:07:24 am »
@Hartmut

Please make sure your Lazarus, FPC and FPC-src are installed correctly. If you have fpc-source installed, it means you're using the installation package provided from Ubuntu. If you manually install Lazarus (using the deb files from SourceForge), it should be fpc-src.

I managed to combine Lazarus from SourceForge with FPC from Ubuntu repository but it didn't work.

You may need to do a clean installation, so use these below to do the full uninstallation first:
01. Uninstall lazarus, fpc, fpc-src
02. Delete ~/.lazarus, except: editoroptions, environmentoptions
03. Delete /etc/fppkg (folder)
04. Delete /etc/fp.*
05. Delete /usr/share/fpcsrc (folder)
06. Delete /usr/lib/fpc (folder)
07. Delete /usr/bin/ppc*

Note:
I keep those 2 files in step #2 because I want to keep some setttings I configured for Lazarus. You can delete them if you want.

After performing the complete uninstallation you now can instal the Lazarus/FPC. You may need a computer reboot. I know it sounds silly :o, but I have bad experience messing the installation, which causes I failed to install Lazarus/FPC no matter how hard I tried. I just shut down my pc, took a break wacthing tv, then came back to install, it worked effortlessly.

For installing Lazarus/FPC, you can follow the link I gave on the previous post.

After the Lazarus installed, you can test it by doing an IDE rebuild:
Lazarus main menu > Tools > Built Lazarus with Profile: Normal IDE

If you don't get any error when building the IDE, you now can continue to do the cross compiling using the steps I gave previously.

Hartmut

  • Hero Member
  • *****
  • Posts: 742
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #20 on: August 28, 2018, 12:59:15 pm »
I deinstalled Lazarus as described in Reply #19.
I made a reboot.
I tried to install Lazarus as described in http://forum.lazarus.freepascal.org/index.php/topic,41524.0.html
I stucked in step 6: gdebi said that there are 63 additional packages neccessary, but could not download them because of Internet connection disabled (screenshot 11 says "Additional packages are downloaded" but there is no progress at all).
After 10-15 minutes I got a timeout error (screenshot 12 says "Could not download all neccessary files").

What shall I do? Install step 6 with Internet connection enabled?

Thanks a lot to Handoko for your continuous help.

SeregaKR

  • New Member
  • *
  • Posts: 35
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #21 on: August 28, 2018, 01:13:51 pm »
Lazarus installation on Linux is broken (I think so). Instead of installing 3 packages you have to install more than 10 from repository.
To fix it you have to purge all fpc* and lazarus* packages, download 3 packages from the web site (http://www.lazarus-ide.org/) and after moving this packages to home folder execute sudo dpkg -i ~/*.deb
DPKG will install all necessary requirements

SeregaKR

  • New Member
  • *
  • Posts: 35
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #22 on: August 28, 2018, 01:15:40 pm »
At least I used this method to deploy Lazarus on Linux Mint on the university computers.

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #23 on: August 28, 2018, 01:48:59 pm »
@Hartmut

Tried @SeregaKR suggestion first, it is much simpler. If it doesn't work then use the installation trick I suggested.

I stucked in step 6: gdebi said that there are 63 additional packages neccessary, but could not download them because of Internet connection disabled ...

Then you may need to do it twice. First with the internet connection enabled, so your Ubuntu can install that 63 additional packages. Follow that steps until finished. But if your Lazarus can't start (because your it uses the its own Lazarus downloaded from Ubuntu repository), you need to repeat the installation again but with the internet connection disabled.

Hartmut

  • Hero Member
  • *****
  • Posts: 742
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #24 on: August 28, 2018, 03:11:53 pm »
I deinstalled "fpc" und "fpc-src" via Synaptic "uninstall completely"
After that Synaptic said, nothing with lazarus* or fpc* was installed
To be sure I added "sudo apt autoremove"
Then I copied fpc_3.0.4-3_amd64.deb, fpc-src_3.0.4-2_amd64.deb and lazarus-project_1.8.4-0_amd64.deb to my home folder and executed "sudo dpkg -i ~/*.deb"

I got the following error message (see screenshot). Translated it means:

fpc-src (3.0.4) is configured ...
dpkg: dependence problemes prevent configuration of lazarus-project:
 lazarus-project depends of libgtk2.0-dev (>= 2.6.0); but:
  package libgtk2.0-dev is not installed.
dpkg: Error when processing package lazarus-project (--install):
 dependence problemes- stays unconfigured
Trigger for man-db (2.8.3-2) are processed ...
Trigger for gnome-menus (3.13.3-11ubuntu1.1) are processed ...
Trigger for desktop-file-utils (0.23-1ubuntu3.18.04.1) are processed ...
Trigger for mime-support (3.60ubuntu1) are processed ...
Trigger for shared-mime-info (1.9-2) are processed ...
Errors occured when processing of:
 lazarus-project

I found "libgtk2.0-dev" in Synaptic that it is installable. Shall I install it?
Must I then repeat "sudo dpkg -i ~/*.deb" ?

Thanks for your help!

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #25 on: August 28, 2018, 03:30:29 pm »
I found "libgtk2.0-dev" in Synaptic that it is installable. Shall I install it?
Must I then repeat "sudo dpkg -i ~/*.deb" ?

Yes, libgtk2.0-dev is required for FPC on Linux Gtk.

@garlar27 collected a list of required libraries for Lazarus/FPC to run properly:
http://forum.lazarus.freepascal.org/index.php/topic,41524.msg288242.html#msg288242

After you installed libgtk2.0-dev, you need to repeat the sudo dpkg -i ~/*.deb.

Hartmut

  • Hero Member
  • *****
  • Posts: 742
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #26 on: August 28, 2018, 06:41:30 pm »
Looks like we've made it!!

Yes, libgtk2.0-dev is required for FPC on Linux Gtk. After you installed libgtk2.0-dev, you need to repeat the sudo dpkg -i ~/*.deb.

I did both and got no error message.
After that I did an IDE rebuild as Handoko requested in reply #19 and got no errors.
Then I could repeat the 9 steps from Handoko's reply #1 without errors.

Now I can switch compiling between 32 bit and 64 bit via Lazarus Menu "Project / Project Options / Compiler Options / Config and Target / Target CPU family": "i386" => 32 bit / "Default" = 64 bit. I am happy!

The 1st program start after switching the bitness gives a debugger error (see screenshot), but you can ignore it and from the 2nd start on it does not come any more.

One question is left (which my sound stupid, but I'm a bloody beginner to Linux): how to start Lazarus normally? From the very 1st installation I had a desktop icon for that, but that was deinstalled.
After a long search I found:
  /usr/bin/lazarus-ide
  /usr/share/lazarus/1.8.4/lazarus
  /usr/share/lazarus/1.8.4/startlazarus
All 3 seem to do the same. But which of them is the "normal" way to start Lazarus? Then I will try to create a desktop Icon for that one...

Again thank you so much to everybody for your valuable help!

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #27 on: August 28, 2018, 06:50:33 pm »
Put this command on your desktop icon or menu item:
startlazarus %f

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #28 on: August 28, 2018, 07:31:56 pm »
/usr/bin/lazarus-ide, like most (all?) lazarus-related commands there, is just a symlink; to, in this case, /usr/share/lazarus/1.8.4/lazarus.

startlazarus is indeed the "correct" incantation :)

And congratulations! In retrospective it should have been obvious that something was very wrong on your installation, so a complete reinstall was the best solution.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Hartmut

  • Hero Member
  • *****
  • Posts: 742
Re: Linux/Ubuntu: how to compile 32 bit programs?
« Reply #29 on: August 28, 2018, 07:50:43 pm »
Because this topic got very long, I will give for future readers a short conclusion about the solution (how to cross compile 32 bit programs with a 64 bit Lazarus):
1) make sure that your lazarus installation is correct. If in doubt:
  a) uninstall all fpc* and lazarus* packages
  b) download 3 packages (fpc, fpc-src and lazarus) from the web site (http://www.lazarus-ide.org/)
  c) move this 3 packages to your home folder
  d) install package "libgtk2.0-dev"
  e) execute sudo dpkg -i ~/*.deb
2) do the 9 steps from reply #1 but take care of the correction for steps 2 and 3 in reply #3

Now you can switch compiling between 32 bit and 64 bit via Lazarus Menu "Project / Project Options / Compiler Options / Config and Target / Target CPU family": "i386" => 32 bit / "Default" = 64 bit.

The 1st program start after switching the bitness gives a debugger error (see screenshot in reply # 26), but you can ignore it and from the 2nd start on it does not come any more.

Good luck! And thanks a lot to all who helped me!

Update: 2 days later my Lazarus installation was automatically deinstalled by an automatic System-Update. So you must either use another installation way or protect your installation. I opened a new topic for that: http://forum.lazarus.freepascal.org/index.php/topic,42393.0.html
« Last Edit: August 30, 2018, 06:46:43 pm by Hartmut »

 

TinyPortal © 2005-2018