7

I installed 64-bit Lazarus and want to generate 32-bit code. When I try to set Target OS to Win32 I get error message

Compiler "C:\Programs\lazarus\fpc\2.6.0\bin\x86_64-win64\fpc.exe" does not support target x86_64-win32

so I guess I need to download and install additional fpc compiler to generate Win32 code and somehow to switch between them in Lazarus IDE.

What is the right way to do it?

kludg
  • 27,213
  • 5
  • 67
  • 118

3 Answers3

4

You need the cross-compiler or simply compile in a 64bit IDE (pragmatic approach).

CodeTyphon works.

3

There is a quick and easy way to cross compile from Win32 to Win64 in Lazarus. I assume that you already have a copy of Lazarus installed on your 32 bit version of Windows.

  1. Download fpc-2.6.2.x86_64-win64.exe (or whichever version is the latest) from the Free Pascal page at SourceForge.

  2. Install, and when it asks for a directory, give it your Lazaus FPC directory and version sub-directory. e.g. C:\lazarus\fpc\2.6.2

  3. All done! :-)

In your Lazarus project, you can now go to Project Options -> Code Generation.

Set:

Target OS = Win64 Target CPU Family = x84_64

Click Ok, and recompile your project. You will now have a 64-bit exe (or dll).

You can switch back and forth between 32-bit compilation and 64-bit compilation any time.

MarkS
  • 31
  • 2
1

Cross compiling is not a feature that "just works" in the standard distribution (either Lazarus or FPC). You'll need to compile the cross compiler yourself, though some are provided but for a very limited host-target pair, namely:

  • i386-win32 to x86_64-win64
  • i386-win32 to arm-wince

After getting the cross compiler (and the cross compiled standard units) installed, you'll need to also cross compile any other 3rd party units you use. Fortunately, you don't need to do this if they are shipped as Lazarus packages, Lazarus will happily do the recompilation for you when you compile your project to the cross target.

LeleDumbo
  • 9,192
  • 4
  • 24
  • 38