Recent

Author Topic: Howto - Cross compile win7-64 to Linux (centos)  (Read 5711 times)

jack616

  • Sr. Member
  • ****
  • Posts: 268
Howto - Cross compile win7-64 to Linux (centos)
« on: March 17, 2015, 03:10:07 pm »
If  you want to do this you may find this worth a read:
I had planned to follow leleedumbo's advice and compile linux to windows but centos had me running round in circles as linux does ... so I went back to a windows to linux cross compile.

This is what I'm doing:

Windows7-64 to centos 6(final)-64 using the Typhon(5.2) install on windows compiling for GTK2
X86_64 on a dual boot system.

This started out bad but there is one piece of information that fixes everything - it took me a long time
to find it but once I had it everything went like a dream. Everyone seems to have the same library problem
but no one ever seems to make the fixes specific and clear anywhere -

1. Install typhon/lazarus with a full compile and ensure the batch menu option 12 is run and
the crossbuild options are right in the typhon (not lazarus IDE) are set right. (I dont know if that's
essential when you do a full typhon build but I did it so I'm reporting it)

2. Go to paragons web site and install their (free) EXT file reader - this reads ext4 but doesnt write - not a problem.
Give this some time to kick in - it doesnt seem to work right away and wants to scan the EXT4 main tree later.

3. In lazarus projects options configure in addtions & overrides for your LCLWidget (GTK2 in my case)

4. In config & target set target OS to linux and Target CPU family to X86_64

5.  I've seen talk of -Xd being needed for the linker - I havn't needed to do that or link smart or anything like that.

6.  Create a simple form with just a close button on it for testing and save the project. 

7.  Click build. This will attempt to find libraries in your linux partition.

You will get a load of linker errors for files not found - just keep clicking build as you clear them.
For me it was just 3 directories - add them to your libraries list in the project  options:
f:\usr\lib64\
f:\lib64\
f:\usr\lib\gcc\x86_64-redhat-linux\4.4.4\

The reason the paths look like windows is just how the (rather impressive) paragon driver translates them.

8. click build again and you will probably get linker errors for2 not found files - then go mad because they
are exactly where the linker says they are.
The two most people seem to complain about are:

/lib64/libpthread.so.0
/usr/lib64/libpthread_nonshared.a

9. The big trick I found was to edit the root .so file that controls these libraries. This turns out to be a simple
ldd text file  - in linux  locate the file libpthread.so  and edit the GROUP line to remove the paths
from the files in brackets giving something like:
GROUP ( libpthread.so.0 libpthread_nonshared.a )

The search paths are the problem not the files- even though the path is correct.

10. click build and you may get one more link error - same as 9 above for libc
look for file libc.so (probably in /lib64)  and do the same as above - remove the paths.

Compile and test your  program on centos - it should run fine.

If anyone wants to do a precis of that please feel free.

All I have to do now is find out which widgets work with gtk and which dont - is there a list anywahere?
(Typhon tends to spoil you by installing everything and the ships cat)

I hope that is useful to someone.
Once you know about the path edit everything seems pretty simple.

jack










marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: Howto - Cross compile win7-64 to Linux (centos)
« Reply #1 on: March 17, 2015, 04:22:43 pm »
5.  I've seen talk of -Xd being needed for the linker - I havn't needed to do that or link smart or anything like that.

Recent versions of the binutils on most *nix distributions skip versions for other architectures, and the auto-added paths are not a problem.

-Xd is a parameter for when that isn't the case.

userx-bw

  • Full Member
  • ***
  • Posts: 178
Re: Howto - Cross compile win7-64 to Linux (centos)
« Reply #2 on: April 10, 2015, 11:15:03 pm »
5.  I've seen talk of -Xd being needed for the linker - I havn't needed to do that or link smart or anything like that.

Recent versions of the binutils on most *nix distributions skip versions for other architectures, and the auto-added paths are not a problem.

-Xd is a parameter for when that isn't the case.

what is this new thing I am now reading about ??

typhon aka  CodeTyphon??


Install typhon/lazarus with a full compile and ensure the batch menu option 12 is run and
the crossbuild options are right in the typhon (not lazarus IDE) are set right. (I dont know if that's
essential when you do a full typhon build but I did it so I'm reporting it)
My Finished Projects
https://sourceforge.net/projects/mhsetroot/
https://sourceforge.net/projects/gmhsetrootfreepascalfrontend/

HP Elitetbook 6930p Dual Core Intel vPro 2.66 gHz
VOID (Linux) 64bit

Jungle

  • New Member
  • *
  • Posts: 25
Re: Howto - Cross compile win7-64 to Linux (centos)
« Reply #3 on: April 09, 2021, 03:34:05 pm »
When I try to cross-compile x86_64 to linux, I get the following error:
Code: Pascal  [Select][+][-]
  1. Compile package FCL 1.0.1: Exit code 1, Errors: 1
  2. math.pp(11,71) Error: Internal error 200208151

which points me to the bug-report with comment:
Quote
Cross-compiling from Win64 to other x86 platforms is not supported due to a lack of 80 bits extended floating point support.

I'm confused.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Howto - Cross compile win7-64 to Linux (centos)
« Reply #4 on: April 11, 2021, 08:53:35 pm »
When I try to cross-compile x86_64 to linux, I get the following error:
Code: Pascal  [Select][+][-]
  1. Compile package FCL 1.0.1: Exit code 1, Errors: 1
  2. math.pp(11,71) Error: Internal error 200208151

which points me to the bug-report with comment:
Quote
Cross-compiling from Win64 to other x86 platforms is not supported due to a lack of 80 bits extended floating point support.

I'm confused.

All x86 targets (no matter if 16-, 32- or 64-bit) make use of the 80-bit Extended floating point type except for one: Win64. If you want to compile for a target that uses Extended (aka any x86 target that is not Win64) you need to be able to do that and the Win64 compiler simply can't. This is the main reason that the FPC team does not provide a native Win64 compiler, because with that you essentially can't compile for any other x86_64 target.

Solution: use the Win32 compiler to compile for x86_64-linux.

Jungle

  • New Member
  • *
  • Posts: 25
Re: Howto - Cross compile win7-64 to Linux (centos)
« Reply #5 on: April 12, 2021, 08:04:43 am »
Solution: use the Win32 compiler to compile for x86_64-linux.

Does it mean that I can simply install 32-bit Lazarus on Win64 and will still be able to compile and debug Win64 apps? Can I install 32-bit Lazarus on Lin64 and build/debug Lin64 apps?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Howto - Cross compile win7-64 to Linux (centos)
« Reply #6 on: April 12, 2021, 09:06:27 am »
Solution: use the Win32 compiler to compile for x86_64-linux.

Does it mean that I can simply install 32-bit Lazarus on Win64 and will still be able to compile and debug Win64 apps?

You need to install the 32-bit IDE as well as the Win64 addon. Of course you'll still need to create the units for x86_64-linux... And regarding debugging at least GDB should work, but fpDebug might not in that case, but martin_fr will have to answer that.

Can I install 32-bit Lazarus on Lin64 and build/debug Lin64 apps?

On Linux you don't need to do that. From a x86_64-linux-based compiler you can reach any other target (as long as you have the correct compiler and RTL). It's only x86_64-win64 that's the odd one out on x86 (any other non-x86 platform will have the same problem).

 

TinyPortal © 2005-2018