Recent

Author Topic: How can I cross-compile from Win32 to Win64 ?  (Read 24151 times)

KlausGunther

  • New Member
  • *
  • Posts: 36
How can I cross-compile from Win32 to Win64 ?
« on: December 22, 2012, 07:24:47 pm »
I'm a newcomer to Lazarus. But I'm a fervent user of Delphi 6 Personal Edition. The main usage is building utilility DLLs for à third party language.

Now, with growing importance of 64 bit systems, I have to convert my DLLs too. Impossible with Delphi 6. Lazarus claims to do it. I installed the version shown in the first attachment. Btw, I'm under Windows XP Pro SP3.

I made a small test DLL, working flawlessly under XP. Now, I tried to generate the 64 bit version. I used the project options to select target OD and CPU. But, with any combination of those 64 bit values (as seen in the first screen shot of the second attachment), I invariably get the same error message informing me that FPC doesn't support this combination (see the second screen shot in the second attachment).

I googled around quite a lot, and I have the impression to do the right thing. What can I do to solve this problem ? I need to cross-compile on e Windows XP PRO sp3 for a generic Windows 64 bit version, be it Vista 64, Seven 64 or W8. Your help would be greatly appreciated !


bobo

  • Full Member
  • ***
  • Posts: 171
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #1 on: December 22, 2012, 08:02:38 pm »
You need to have the fpc units compiled for the target platform/cpu before that will work.

Did you check http://wiki.freepascal.org/Cross_compiling ?

I use the 32bit Lazarus on Windows (both 32 and 64bit Windows) to cross compile for both 32bit and 64bit Windows.
For the fpc units, you will need the FPC source code of at least the latest stable release to build the units (even before you do anything in Lazarus).
The end goal of this is to have within your "fpc_compiler_dir" both a /units/i386-win32 and /units/x86_64-win64 so Lazarus can pick those units for whichever target cpu/platform you are compiling your program to.

KlausGunther

  • New Member
  • *
  • Posts: 36
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #2 on: December 22, 2012, 09:09:51 pm »
Yes, I had a look on that. But I'm not yet used to Lazarus and this does confuse me a little.

In a Dos Window, I navigated to the FPC folder, and typed:
make all OS_TARGET=win64 CPU_TARGET=x86_64
as stated on the page you indicated. Make version 5.2 starts, but stope with the error message:
Fatal: Un able to open makefile
I have the Win64 and X86_64 subfolder, however.

I'm obviously missing something...

bobo

  • Full Member
  • ***
  • Posts: 171
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #3 on: December 23, 2012, 02:50:26 am »
Do you have the FPC sources or just installed Lazarus/FPC binary packages?
You need the FPC sources from its SVN repository in order to compile the whole FPC.
You also need the latest fpc stable binaries and binutils, etc.

There are probably more information in the wiki - and elsewhere -  about how to compile FPC from SVN sources, it is not a trivial task, one can spend a day or two until figures it out.

Maybe it would be easier for you to install a 32bit Lazarus and a 64bit Lazarus both, on a 64bit Windows machine. Then the 32bit one compiles by default to 32bit and the 64bit one to 64bit.
« Last Edit: December 23, 2012, 02:53:17 am by bobo »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #4 on: December 23, 2012, 05:22:30 am »
Quote
Yes, I had a look on that. But I'm not yet used to Lazarus and this does confuse me a little.

In a Dos Window, I navigated to the FPC folder, and typed:
make all OS_TARGET=win64 CPU_TARGET=x86_64
Is this fpc folder under lazarus that you get from the installer? If yes, then it's unfortunately insufficient because it doesn't contain the compiler source, only runtime library and packages. You have to download the whole fpc source (doesn't have to be svn version, the one that matches your version (2.6.0?) should be OK). Then you can do above command.

KlausGunther

  • New Member
  • *
  • Posts: 36
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #5 on: December 23, 2012, 09:35:15 am »
Thanks for these hints. Effectively, I installed the binary distribution and I didn't specifically download a source distribution. I'll look for that now and come back later.

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #6 on: December 23, 2012, 09:40:02 am »
Or you can use CodeTyphon with build in cross-compile solution

KlausGunther

  • New Member
  • *
  • Posts: 36
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #7 on: December 23, 2012, 09:57:35 am »
Thanks, Dibo! I'll have a look on that - it's actually downloading.

Back to the Lazarus and FPC sources, 4'm really confused by the profusion of different source distributions. For my problem: executing on a 32 bit Windows XP Pro SP3, I need tu generate DLLs for a Windowd 64 bit environment (Vista 64, Seven 64 or W8) in native mode. Is this link what I need:
ftp://freepascal.dfmk.hu/pub/lazarus/snapshots/fpc-src-2.6.0-0.laz.x86_64.rpm
I don't know *.rpm files. How do I open them ? Sorry for my ignorance.

KlausGunther

  • New Member
  • *
  • Posts: 36
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #8 on: December 23, 2012, 12:34:55 pm »
Now, that CodeTyphon pack was a big one ! After 2 hours of compilation and linking, it's installed and running.

But CodeTyphon too compiles only for Win32 on my XP Pro SP3 ! No cross-compiling for X86-WIN64 avaiable ! In the CodeTyphon Center, in the Cross-Build menu, there is a line
FPC build cross element X86_64-win64
I clicked on it, but noting happens. The cross element is not shown under the FPC compiler line, the corresponding folder is not added to the CodeTyphon\FPC\bin folder, and I cannot select these code generation options in the project options.

I'm back to my initial question:
How can I cross-compile a project on a 32 bit Windows XP SP3 for a target Windows 64 bit (Vista 64, Seven 64 or W8) ?
This is crucial for me !

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #9 on: December 23, 2012, 03:21:54 pm »
Quote
Is this link what I need:
ftp://freepascal.dfmk.hu/pub/lazarus/snapshots/fpc-src-2.6.0-0.laz.x86_64.rpm
I don't know *.rpm files. How do I open them ? Sorry for my ignorance.
The source is actually portable, but this one is packaged specially for Red Hat based Linux system. You can take this one instead. Simply extract somewhere and do that
Code: [Select]
make all OS_TARGET=win64 CPU_TARGET=x86_64 && make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=<directory of your choice, but better under the same directory as your current fpc, e.g. C:/lazarus/fpc/2.6.0 (note the FORWARD slash!) so target switching can be done easily>thing on the top of resulting directory tree. To check, it should have a Makefile and a bunch of directories: compiler, ide, libgdb, installer, packages, rtl, utils and tests.

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #10 on: December 23, 2012, 03:35:40 pm »
Quote
How can I cross-compile a project on a 32 bit Windows XP SP3 for a target Windows 64 bit (Vista 64, Seven 64 or W8) ?
This is crucial for me !
If you have some problem with CodeTyphon, better to contact the forum of Pilot Logic, they have the answer :
http://www.pilotlogic.com/sitejoom/

Have you the possibility to install Linux ?

I use Ubuntu 32 bits and can cross-compil for Win 32, Win 64, Linux 32, Linux 64 and Mac Osx 32. I use CodeTyphon.

I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

KlausGunther

  • New Member
  • *
  • Posts: 36
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #11 on: December 23, 2012, 04:40:09 pm »
@Leledumbo:
Thank you for your advice. I'll do that - thats just the 3rd FPC (1 binary from SourceForec, 1 from Lazarus, 1 from CodeTyphon). I will come back with the result.

@Fred vS
I will try their forum. Thank you for the hint. And no, I cannot install Ubuntu or another Unix clone. My system disk is too small to reserve à separate Unix partition, and I have only a single notebook. I have a Ubunto Live CD, but obviously, this isn't enough. So, I'm really stuck with XP...

EDIT

The PilotLogic people answered:
Quote
Sir
Win32 ->CrossBuild->Win64 ?
we have problem with this

My suggestion is to have a win64 PC

I insisted a bit, but I'm not very hopefull.
« Last Edit: December 23, 2012, 05:56:24 pm by KlausGunther »

KlausGunther

  • New Member
  • *
  • Posts: 36
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #12 on: December 23, 2012, 06:09:15 pm »
@Leledumbo:

- download and unzip of FPC sources OK

- 1174 command file errors trying the following commands:
Quote
make all OS_TARGET=win64 CPU_TARGET=x86_64
or
make crossinstall OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=C:/lazarus/fpc/2.6.0_64

Any suggestions ?

bobo

  • Full Member
  • ***
  • Posts: 171
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #13 on: December 23, 2012, 08:21:39 pm »
Without the first error message it is hard to see what the problem is, but my guess is that you do not have the crosscompiling binutils. Just unpacking the FPC sources and trying to build them with a 32bit Lazarus install will not work, because it does not have the needed binutils.

I can post my binaries in a zip if you wish to spare you the pain of finding everyting.

KlausGunther

  • New Member
  • *
  • Posts: 36
Re: How can I cross-compile from Win32 to Win64 ?
« Reply #14 on: December 23, 2012, 09:07:02 pm »
Thank you very much. I'll use them as soon as I'll find them.

After heavy googling, I found the following link:
http://fr.sourceforge.jp/projects/sfnet_freepascal/downloads/Win32/2.6.0/fpc-2.6.0.x86_64-win64.exe/
which is supposed to be the cross compiler option for X86-WIN64. It installed into lazarus without a problem, and I could finally change the target OS and CPU in the progrfam options. On compilation, it compiled automatically a lot of thing, and finally my DLL. But the resulting file is HUGE - for 2 tiny test functions, more than 14 Mb ! The Delphi DLL containing over 100 functions takes 1.2 MB.

I still have to check the functionality of the result, but the nes software correctly installed into the ....\fpc\2.6.0\units\ folder.

Do you think I got the right module ?

 

TinyPortal © 2005-2018