Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-08

Using Laz 32bits to compile 64bits

20 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcos Douglas

Hi,
My env is WinXP (3 bits, of course), FPC 2.5.1 (/branches_2_6) and Lazarus 0.9.31.
I have FPC and Lazarus working on my notebook and I have a HD external too (in any PC I can use the FPC/Lazarus, just using --pcp to start it).

Now I have to compile a console program (this is the first) to use in a Win7 64bits dual core.

My questions are:
1. I can use Lazarus 32bits in a machine 64bits but compile a program to 64bits?
2. The make, to compile FPC, knows about if the machine is 64bits or I have to type a parameter?

[1] http://wiki.freepascal.org/Installing_Lazarus#Compiling.2Finstalling_FPC_and_Lazarus_from_Sources_of_SVN_.28Win32.29

Marcos Douglas

Reply by email

Marcos Douglas
to Hans-Peter Diettrich: I encountered many problems, in compiling 64 bit applications on a 64 bit Windows. One…
Hans-Peter Diettrich wrote 20 lines
Marcos Douglas schrieb: > My questions are: > 1. I can use Lazarus 32bits in a machine 64bits but compile a program to > 64bits? > 2. The make, to compile FPC, knows about if the machine is 64bits or I > have to type a parameter? I encountered many problems, in compiling 64 bit applications on a 64 bit Windows. One problem is the bad guess of fpc.exe, to build for 32 bit by default. More problems result from the tools in the fpc/bin directory, whose 32 and 64 bit versions have the same name. This discourages to have the fpc/bin directory in the PATH, in contrast to the default FPC/Lazarus installation. Finally the debugger seems to have problems with 32 and 64 bit applications (this may have changed in the meantime). For building FPC I replace the PATH entirely by the appropriate fpc/bin directory, which contains all required tools (what is not guaranteed by the standard installation). It may be a good idea to have isolated accounts, containing the 32/64 bit installations of FPC and Lazarus.

I never used PATH to compile or use them.
First I'm trying to compile FPC in a Win7 64bits.
I use this script[1] to compile FPC 32bit with success. So, I changed the script to:

set myVERSION=2.7.1
set myROOT=c:\freepascal
set myFPC=%myROOT%\compiler\%myVERSION%
set myBINUTILS=%myROOT%\binutils
set PATH=%myBINUTILS%\x86_64-win64;%myFPC%\bin\i386-win32

cd %myFPC%

make clean all install OS_TARGET=win64 CPU_TARGET=x86_64 INSTALL_PREFIX=%myFPC% PP=%myBINUTILS%\ppc386.exe
DATA2INC=%myFPC%\utils\data2inc.exe

As you can see, I only includes: OS_TARGET=win64 CPU_TARGET=x86_64 parameters.

Question:
I can compile a new fpc.exe to 64bit using a ppc386.exe 32bit version, on a machine 64bit?

[1] http://wiki.freepascal.org/Installing_Lazarus#Compiling.2Finstalling_FPC_and_Lazarus_from_Sources_of_SVN_.28Win32.29

Marcos Douglas

Marcos Douglas

Reply by email

Vincent Snijders
to Marcos Douglas: My env is WinXP (3 bits, of course), FPC 2.5.1 (/branches_2_6) and Lazarus 0.9.31. I have…

2011/8/19 Marcos Douglas :

Show quoted text 12 lines
Hi, My env is WinXP (3 bits, of course), FPC 2.5.1 (/branches_2_6) and Lazarus 0.9.31. I have FPC and Lazarus working on my notebook and I have a HD external too (in any PC I can use the FPC/Lazarus, just using --pcp to start it). Now I have to compile a console program (this is the first) to use in a Win7 64bits dual core. My questions are: 1. I can use Lazarus 32bits in a machine 64bits but compile a program to 64bits?

Yes, that is possible. Even on a 32 bits machine you can compile a program to 64 bits. It is called cross compiling.

2. The make, to compile FPC, knows about if the machine is 64bits or I have to type a parameter?

Set the target processor and the target OS in Lazarus.

For more details on compiling the fpc units for win64, see the buildfaq. www.stack.nl/~marcov/buildfaq.pdf

Vincent

Reply by email

Hans-Peter Diettrich
to Marcos Douglas: My env is WinXP (3 bits, of course), FPC 2.5.1 (/branches_2_6) and Lazarus 0.9.31. I have…
My questions are: 1. I can use Lazarus 32bits in a machine 64bits but compile a program to 64bits? 2. The make, to compile FPC, knows about if the machine is 64bits or I have to type a parameter?

I encountered many problems, in compiling 64 bit applications on a 64 bit Windows. One problem is the bad guess of fpc.exe, to build for 32 bit by default. More problems result from the tools in the fpc/bin directory, whose 32 and 64 bit versions have the same name. This discourages to have the fpc/bin directory in the PATH, in contrast to the default FPC/Lazarus installation. Finally the debugger seems to have problems with 32 and 64 bit applications (this may have changed in the meantime).

For building FPC I replace the PATH entirely by the appropriate fpc/bin directory, which contains all required tools (what is not guaranteed by the standard installation). It may be a good idea to have isolated accounts, containing the 32/64 bit installations of FPC and Lazarus.

DoDi

Reply by email

Sven Barth
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 13 lines
Marcos Douglas schrieb: > Question: > I can compile a new fpc.exe to 64bit using a ppc386.exe 32bit version, > on a machine 64bit? Yes and no ;-) Yes, you can create an ppcrossx64.exe, along with the 64 bit libraries, using ppc386.exe. No, fpc.exe doesn't compile anything itself, it only calls the compiler for the selected target.

The point is that a fpc.exe compiled for 32bit will select the 32bit compiler (ppcx86) as default while the one compiled for 64bit will select the 64bit compiler as default (ppcx64). So it does matter what platform you compile fpc.exe for.

Regards,
Sven

Reply by email

Hans-Peter Diettrich
to Sven Barth
The point is that a fpc.exe compiled for 32bit will select the 32bit compiler (ppcx86) as default while the one compiled for 64bit will select the 64bit compiler as default (ppcx64). So it does matter what platform you compile fpc.exe for.

Thanks, this explains the strange behaviour of fpc.exe on 64 bit Windows. It seems to be required to have FPC and Lazarus installed in both 32 and 64 bit versions, in order to create and debug applications for both targets.

DoDi

Reply by email

Graeme Geldenhuys
to Marcos Douglas: My env is WinXP (3 bits, of course), FPC 2.5.1 (/branches_2_6) and Lazarus 0.9.31. I have…
Marcos Douglas wrote
My questions are: 1. I can use Lazarus 32bits in a machine 64bits but compile a program to 64bits?

I have long since given up on cross-compiling. And even when it did work (successfully generated an executable), that executable often crashed when run. So now I simply have one VM session for each OS we want to target. I have build scripts on each, so no need to open IDE's compile packages, change compiler settings for release versions etc. Simply load the VM, and run the build script. The build script automatically pulls the latest code and compiles with release build compiler settings.

This works perfectly for our company for over a year, and we will continue using this method in the future.

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Marcos Douglas
to Hans-Peter Diettrich: Yes and no ;-) Yes, you can create an ppcrossx64.exe, along with the 64 bit libraries,…
Hans-Peter Diettrich wrote 10 lines
Marcos Douglas schrieb: > Question: > I can compile a new fpc.exe to 64bit using a ppc386.exe 32bit version, > on a machine 64bit? Yes and no ;-) Yes, you can create an ppcrossx64.exe, along with the 64 bit libraries, using ppc386.exe.

Sorry, do I need ppcrossx64.exe?
I do not want use cross-compile. I said I have two Windows versions: XP and 7. So, I want to use the same FPC/Lazarus code (hd external) and run a script in WinXP and create my app and, after run other script and create the same app, but to 64bit target.

I is not necessary to compile the app 64bit on Win32.

Marcos Douglas

Reply by email

Marcos Douglas
to Sven Barth: The point is that a fpc.exe compiled for 32bit will select the 32bit compiler (ppcx86) as…
Sven Barth wrote 20 lines
Am 20.08.2011 05:01, schrieb Hans-Peter Diettrich: > > Marcos Douglas schrieb: > >> Question: >> I can compile a new fpc.exe to 64bit using a ppc386.exe 32bit version, >> on a machine 64bit? > > Yes and no ;-) > > Yes, you can create an ppcrossx64.exe, along with the 64 bit libraries, > using ppc386.exe. > > No, fpc.exe doesn't compile anything itself, it only calls the compiler > for the selected target. The point is that a fpc.exe compiled for 32bit will select the 32bit compiler (ppcx86) as default while the one compiled for 64bit will select the 64bit compiler as default (ppcx64). So it does matter what platform you compile fpc.exe for.

So, to compile the first version of FPC 64 I have to download a ppcx64.exe and run make. Is that?

Marcos Douglas

Reply by email

Marcos Douglas
to Graeme Geldenhuys: I have long since given up on cross-compiling. And even when it did work (successfully…
Graeme Geldenhuys wrote 9 lines
On 19 August 2011 15:45, Marcos Douglas wrote: > > My questions are: > 1. I can use Lazarus 32bits in a machine 64bits but compile a program to 64bits? I have long since given up on cross-compiling. And even when it did work (successfully generated an executable), that executable often crashed when run.

This is my fear. Therefore I said that I will compile in each OS.

Show quoted text 9 lines
So now I simply have one VM session for each OS we want to target. I have build scripts on each, so no need to open IDE's compile packages, change compiler settings for release versions etc. Simply load the VM, and run the build script. The build script automatically pulls the latest code and compiles with release build compiler settings. This works perfectly for our company for over a year, and we will continue using this method in the future.

But you have a copy of FPC for each OS?
You can use different sources, no? I would like to use a only source (FPC and Lazarus) and scripts to compile for each OS (in my case, today, just do WinXP and Win7).

Marcos Douglas

Reply by email

Marcos Douglas
to Vincent Snijders: 2011/8/19 Marcos Douglas : Yes, that is possible. Even on a 32 bits machine you can…
Vincent Snijders wrote 15 lines
2011/8/19 Marcos Douglas : > Hi, > My env is WinXP (3 bits, of course), FPC 2.5.1 (/branches_2_6) and > Lazarus 0.9.31. > I have FPC and Lazarus working on my notebook and I have a HD external > too (in any PC I can use the FPC/Lazarus, just using --pcp to start > it). > > Now I have to compile a console program (this is the first) to use in > a Win7 64bits dual core. > > My questions are: > 1. I can use Lazarus 32bits in a machine 64bits but compile a program to 64bits? Yes, that is possible. Even on a 32 bits machine you can compile a program to 64 bits. It is called cross compiling.

I don't want to use cross compile. I want use a same code of FPC to compile in each OS.

Show quoted text 6 lines
> 2. The make, to compile FPC, knows about if the machine is 64bits or I > have to type a parameter? Set the target processor and the target OS in Lazarus. For more details on compiling the fpc units for win64, see the buildfaq. www.stack.nl/~marcov/buildfaq.pdf

I will see.

Marcos Douglas

Reply by email

Sven Barth
to Marcos Douglas: So, to compile the first version of FPC 64 I have to download a ppcx64.exe and run make.…
Marcos Douglas wrote 24 lines
On Sat, Aug 20, 2011 at 5:51 AM, Sven Barth wrote: > Am 20.08.2011 05:01, schrieb Hans-Peter Diettrich: >> >> Marcos Douglas schrieb: >> >>> Question: >>> I can compile a new fpc.exe to 64bit using a ppc386.exe 32bit version, >>> on a machine 64bit? >> >> Yes and no ;-) >> >> Yes, you can create an ppcrossx64.exe, along with the 64 bit libraries, >> using ppc386.exe. >> >> No, fpc.exe doesn't compile anything itself, it only calls the compiler >> for the selected target. > > The point is that a fpc.exe compiled for 32bit will select the 32bit > compiler (ppcx86) as default while the one compiled for 64bit will select > the 64bit compiler as default (ppcx64). So it does matter what platform you > compile fpc.exe for. So, to compile the first version of FPC 64 I have to download a ppcx64.exe and run make. Is that?

fpc.exe is AFAIK only compiled if you run a "make install" or you run "make fpc" in the "compiler/utils" directory (not exactly sure about the last one).

Regards,
Sven

Reply by email

Florian Klämpfl
to Graeme Geldenhuys: I have long since given up on cross-compiling. And even when it did work (successfully…
Graeme Geldenhuys wrote 7 lines
On 19 August 2011 15:45, Marcos Douglas wrote: > > My questions are: > 1. I can use Lazarus 32bits in a machine 64bits but compile a program to 64bits? I have long since given up on cross-compiling.

It depends on the OS: Win32/Win64 cross compilation works perfectly because
- of the internal linker
- dyn. libraries not needed at the linking stage
- lazier library dependencies
So it's not fpc's/lazarus's fault but a problem of the platform.

Reply by email

Marcos Douglas
to Sven Barth: fpc.exe is AFAIK only compiled if you run a "make install" or you run "make fpc" in the…
Sven Barth wrote 33 lines
Am 20.08.2011 20:05, schrieb Marcos Douglas: > > On Sat, Aug 20, 2011 at 5:51 AM, Sven Barth > ?wrote: >> >> Am 20.08.2011 05:01, schrieb Hans-Peter Diettrich: >>> >>> Marcos Douglas schrieb: >>> >>>> Question: >>>> I can compile a new fpc.exe to 64bit using a ppc386.exe 32bit version, >>>> on a machine 64bit? >>> >>> Yes and no ;-) >>> >>> Yes, you can create an ppcrossx64.exe, along with the 64 bit libraries, >>> using ppc386.exe. >>> >>> No, fpc.exe doesn't compile anything itself, it only calls the compiler >>> for the selected target. >> >> The point is that a fpc.exe compiled for 32bit will select the 32bit >> compiler (ppcx86) as default while the one compiled for 64bit will select >> the 64bit compiler as default (ppcx64). So it does matter what platform >> you >> compile fpc.exe for. > > So, to compile the first version of FPC 64 I have to download a > ppcx64.exe and run make. Is that? fpc.exe is AFAIK only compiled if you run a "make install" or you run "make fpc" in the "compiler/utils" directory (not exactly sure about the last one).

I didn't know that. Well... I always ran 'make install'.

I know the fpc.exe just calls ppc386.exe but what advantages to do this? Well, this is another thread...

Marcos Douglas

Reply by email

Florian Klämpfl
to Marcos Douglas
Marcos Douglas wrote
I know the fpc.exe just calls ppc386.exe but what advantages to do this?

Regardless of the target processor, it's enough just to call fpc to get an executable for the current platform.

Reply by email

Marcos Douglas
to Hans-Peter Diettrich: fpc doesn't "just call", it calls the compiler for the given target. ppc386 may ignore…
Hans-Peter Diettrich wrote 8 lines
Marcos Douglas schrieb: > I know the fpc.exe just calls ppc386.exe but what advantages to do > this? Well, this is another thread... fpc doesn't "just call", it calls the compiler for the given target. ppc386 may ignore the target options, or complain about a non-Win32 target.

Oh, I did know that. Thanks.

Way up in this thread you presented your installation script. Did you ever use it? It looks as if you only ask, and never try to run any of your or other people suggestions.

What? Of course I use it!
I didn't understand you did you mean... could you explain? This script works to Win32...

BTW, the simplest way to install fpc on Windows is using an snapshot: http://www.hu.freepascal.org/lazarus/

I install my FPC and Lazarus using the script did you talk about. Only using SVN.

Marcos Douglas

Reply by email

Hans-Peter Diettrich
to Marcos Douglas: I didn't know that. Well... I always ran 'make install'. I know the fpc.exe just calls…
I know the fpc.exe just calls ppc386.exe but what advantages to do this? Well, this is another thread...

fpc doesn't "just call", it calls the compiler for the given target. ppc386 may ignore the target options, or complain about a non-Win32 target.

Way up in this thread you presented your installation script. Did you ever use it? It looks as if you only ask, and never try to run any of your or other people suggestions.

BTW, the simplest way to install fpc on Windows is using an snapshot: http://www.hu.freepascal.org/lazarus/

DoDi

Reply by email

Marcos Douglas
to Florian Klämpfl: Regardless of the target processor, it's enough just to call fpc to get an executable for…
Florian Kl?mpfl wrote 6 lines
Am 20.08.2011 21:19, schrieb Marcos Douglas: > I know the fpc.exe just calls ppc386.exe but what advantages to do > this? Regardless of the target processor, it's enough just to call fpc to get an executable for the current platform.

The fpc.exe calls the ppcXXX for each target?

BTW, look the attachment. Why there is a some exe files in these paths? IMHO, Isn't better that each binary stay in \i386-win32 or \x86_64-win64 directories, for example?

I can use a single FPC source to work with two processors targets? The binaries above will be replaced when I compile the last time?

Marcos Douglas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: printscreen.jpg
Type: image/jpeg
Size: 54368 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110820/24db9553/attachment-0001.jpg>

Reply by email

Marcos Douglas
to Graeme Geldenhuys: I have long since given up on cross-compiling. And even when it did work (successfully…
Graeme Geldenhuys wrote 17 lines
On 19 August 2011 15:45, Marcos Douglas wrote: > > My questions are: > 1. I can use Lazarus 32bits in a machine 64bits but compile a program to 64bits? I have long since given up on cross-compiling. And even when it did work (successfully generated an executable), that executable often crashed when run. So now I simply have one VM session for each OS we want to target. I have build scripts on each, so no need to open IDE's compile packages, change compiler settings for release versions etc. Simply load the VM, and run the build script. The build script automatically pulls the latest code and compiles with release build compiler settings. This works perfectly for our company for over a year, and we will continue using this method in the future.

Could you explain more about how do you works with scripts? For example, how do you updates ALL script if you add one more lib (sources)?
Do you have a FPC and Lazarus installed in each VM?

Marcos Douglas

Reply by email