Recent

Author Topic: Installing Lazarus on Linux to compile in linux, win32 and macOS  (Read 25249 times)

plakkies

  • New Member
  • *
  • Posts: 16
Installing Lazarus on Linux to compile in linux, win32 and macOS
« on: September 26, 2012, 03:05:25 pm »
My first goal was to get Lazarus working just to compile a program for linux. This I found very easy and was able to get this working on every distro I tried. There were a few hicups but the forums and wiki helped out great.

My next goal was to get it to compile for Windows. This has been an uphill battle with no end in sight. I referred mainly to http://wiki.freepascal.org/Cross_compiling_for_Win32_under_Linux and I have tried several different distros and versions with varied results but I have not gotten even close to compiling for windows.

I have been using a virtual machine with a clean install of whatever distro each time. Has anyone gotten this right? Can I get an image of a VM that someone has got it right in?
I have been trying to get this right for over 4 months and Its getting annoying.

Is there possibly an ISO with a linux distro that would come with this pre installed?

This seems to me like the ideal install, what am I missing? Any help will be highly appreciated.

plakkies

  • New Member
  • *
  • Posts: 16
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #1 on: October 01, 2012, 07:54:58 am »
Come on. There must be someone who has gotten this right. What am I missing?

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #2 on: October 01, 2012, 07:58:29 am »
See my other post on building a Linux boot cd with cross compile functionality.

Somebody probably has this right - but there's no ISO around except for the android cross compiler.

If you don't say exactly what you tried and where you failed:
1. how do you think others can help you
2. how can you help improve the documentation?

NB: for cross compiling to OSX you will need to copy files from your OSX machines; there's a wiki article on that too.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #3 on: October 01, 2012, 09:58:19 am »
My lin32 can compile for win32 and win64, using that article (and the general cross compiling article) as a base. If you don't say exactly where you failed and what you got so far, it would be difficult to help. Note that as oppose to the article, my installation does NOT use cross binutils, I rely on internal assembler/linker that fpc has for those platforms. So these two are actually the easiest ever.

plakkies

  • New Member
  • *
  • Posts: 16
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #4 on: October 02, 2012, 02:40:35 pm »
Thanks for the responses. Ive struggled so much so far I guess an easy answer is not going to happen.

To keep this short Ive taken the one install that seems to have taken me the furtherest.
This is running on Linux debian 2.6.32-5-686 #1 SMP Sun May 6 04:01:19 UTC 2012 i686 GNU/Linux

I have gotten to the point in the guide where I must run 'buildcrosssnaphot.sh'

I get the following output

lazarus@debian:~/Downloads/binutils-2.22/install/cross$ sh buildcrosssnaphot.sh
HOST platform is unknown-linux
Building i386-linux
i386-linux FAILES
Building i386-win32
i386-win32 FAILES
[: 133: i386-linux: unexpected operator
lazarus@debian:~/Downloads/binutils-2.22/install/cross$

Im not sure what you mean by not using cross binutils. This is probably part of the problem, however many times I read it The whole cross compiling proccess does not make 100% sense to me. I guess if I understood the whole process it would help me to sort it out as well.

Thanks again for the help

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #5 on: October 02, 2012, 03:46:59 pm »
Note that as oppose to the article, my installation does NOT use cross binutils, I rely on internal assembler/linker that fpc has for those platforms. So these two are actually the easiest ever.

That sounds very nice, could you please write some instructions for that setup?  In the existing article or elsewhere...
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #6 on: October 02, 2012, 05:17:24 pm »
Quote
I have gotten to the point in the guide where I must run 'buildcrosssnaphot.sh'
Hmm... I don't use any of those scripts, but seeing your output:
Quote
lazarus@debian:~/Downloads/binutils-2.22/install/cross$ sh buildcrosssnaphot.sh
seems like you're executing the script in the wrong directory. buildcrossbinutils should be used at this step (since you're building cross binutils). buildcrosssnaphot should be executed on fpcbuild directory. You can try continuing the process and post further errors here.
Quote
That sounds very nice, could you please write some instructions for that setup?  In the existing article or elsewhere...
I'm too lazy to edit the article for now :P, but here's what I did:
  • Download fpc source (complete one, it should have compiler directory instead of just packages and rtl)
  • for win32, cd to rtl and execute: make all OS_TARGET=win32 && sudo make crossinstall OS_TARGET=win32 INSTALL_PREFIX=/usr
    then cd to packages and repeat the command (same arch doesn't require different compiler)
  • for win64, cd to the top directory and execute: make all OS_TARGET=win64 CPU_TARGET=x86_64 && sudo make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=/usr
Note that above INSTALL_PREFIX assume fpc lib to be in /usr/lib/fpc. After installing, don't forget to create symlink to /usr/lib/fpc/<fpc version>/ppcrossx64 in /usr/bin (if you have fpc binaries there).

I have self-built script to maintain all my fpc targets when I update from svn (currently I target i386-linux, i386-win32, x86_64-win64, arm-linux, jvm-java and jvm-android).
« Last Edit: October 02, 2012, 05:19:07 pm by Leledumbo »

plakkies

  • New Member
  • *
  • Posts: 16
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #7 on: October 03, 2012, 09:40:26 am »
@Leledumbo

Can I assume you use arch linux? I will then use a clean arch install and start from scratch. just to make sure Ive done everything right and use the latest versions.


Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #8 on: October 03, 2012, 02:10:44 pm »
Quote
Can I assume you use arch linux?
No, I use Kubuntu. But I don't take neither fpc nor lazarus from repository, everything is built from source (svn), except for fpc stable version (for bootstrapping in case current revision can't be compiled with previous one I have).

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #9 on: October 04, 2012, 06:53:56 pm »
I'm too lazy to edit the article for now :P, but here's what I did:

Thanks ;)
I might put that on wiki if I find the time. So far I've put it on my ToDo list on the wiki. Perhaps someone does that even sooner ;)
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

plakkies

  • New Member
  • *
  • Posts: 16
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #10 on: October 10, 2012, 01:16:21 pm »
Its been a while , it seems I have all the luck. took me a while to get kubuntu running. I guess with all the issues I find I can only learn more.

Ive gotten the furtherest Ive been so far. I did the following
Installed kubuntu in a VM with guest additions (took way longer than I though)
Followed http://wiki.freepascal.org/Cross_compiling_for_Win32_under_Linux
I had a problem with "BINUTILSPATH=~/download/" as my download folder was "Downloads" I changed the value in the file to be appropriate, this was a bad idea, lots of errors. Changing the Downloads folder to download solved plenty of errors.
When I got to the part about changing the fpc.cfg file I realised I needed to install lazarus in the first place. I proceeded to do this.
Then I changed the fpc.cfg file
The next step shows to go to the Lazarus directory(i dont know where this is) or to do a few things in the IDE. When I do those things in the IDE I get the following two errors one after the other.

The project uses target OS=win32 and CPU=i386.
The system.ppu for this target was not found in the FPC binary directories.
Make sure fpc is installed correctly for this target and the fpc.cfg contains the right directories.

and

This set of options to build Lazarus is not supported by this installation.
The directory "/usr/lib/lazarus/0.9.30.2/lcl" is not writable.
See the Lazarus website for other ways to install Lazarus.

Any ideas?
btw I love that I can copy and paste dialog boxes in linux, you cant do that in windows


plakkies

  • New Member
  • *
  • Posts: 16
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #11 on: October 10, 2012, 04:17:12 pm »
Update:

I chowned /usr/lib/lazarus second error is gone now.  :) First error is still there :(

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #12 on: October 10, 2012, 04:51:12 pm »
Quote
The project uses target OS=win32 and CPU=i386.
The system.ppu for this target was not found in the FPC binary directories.
Clear enough, I guess. Do you have <fpc>/units/i386-win32 besides i386-linux? And if you do, make sure it has all i386-win32 rtl units (and all other units you needed). And if you're sure they're all there, post -Fu lines in your fpc.cfg.

plakkies

  • New Member
  • *
  • Posts: 16
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #13 on: October 11, 2012, 06:46:57 am »
Ok

The only place I find i386-win32 is
/usr/lib/lazarus/0.9.30.2/lcl/units/i386-win32
is that the right place? Im not too sure about that one.

Is this the part of fpc.cfg you wanted?

#IFDEF win32
-Fu~/cross_fpc/lib/fpc/$fpcversion/cross/units/i386-win32/
-Fu~/cross_fpc/lib/fpc/$fpcversion/cross/units/i386-win32/*
-Fu~/cross_fpc/lib/fpc/$fpcversion/cross/units/i386-win32/rtl
-XPi686-mingw32-
-FD~/cross_fpc/cross/bin
#ELSE linux
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#-Fu~/fpc/packages/*;~/fpc/rtl/linux
#ENDIF


and now that I've looked at the above I checked and I see that ~/cross_fpc/lib/fpc/ does not exist. ~/cross_fpc/lib exists and there are plenty other things there as well. Could this have something to do with me installing lazarus at the wrong stage?

Thanks for all the help

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Installing Lazarus on Linux to compile in linux, win32 and macOS
« Reply #14 on: October 11, 2012, 11:20:02 am »
Quote
The only place I find i386-win32 is
/usr/lib/lazarus/0.9.30.2/lcl/units/i386-win32
is that the right place? Im not too sure about that one.
No, I'm asking about FPC. So, if your normal FPC is in /usr/lib/fpc, normally you would have /usr/lib/fpc/<fpcversion>/units/i386-linux containing rtl and packages units. In my installation, and since it's possible (so I don't need to ifdef my fpc.cfg), I also have /usr/lib/fpc/<fpcversion>/units/i386-win32 for win32 cross compilation. In case you want to use different directory, feel free but your fpc.cfg would contain ifdef then.
Quote
Is this the part of fpc.cfg you wanted?
Yes, and apparently you already have the ifdef. Normally, you only need 1 -Fu, and it should point to directory above + wildcard (e.g. /usr/lib/fpc/<fpcversion>/units/i386-win32/*) because below every directory under i386-win32 are where the .ppu and .o lie, and this is where -Fu should point. The -XP and -FD is not really required since by default win32 target will use internal assembler and linker, but it's OK to have.
Quote
~/cross_fpc/lib exists and there are plenty other things there as well. Could this have something to do with me installing lazarus at the wrong stage?
I guess not, just some wrong paths, correct it to yours. Just remember the structure above, it should be the same for any target as long as the host is linux. I think I'll create an article to setup a cross compilation environment on linux for any target.

 

TinyPortal © 2005-2018