Sign in Join

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

Mailing lists / fpc-pascal / 2023-03

Downloaded cross-compiler from Sourceforge - wiki incorrect?

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Bo Berglund

I tried to add a cross-compiler for Win32 to my existing Lazarus 2.2.4 installation on Windows 10 x64.

So I followed the instructions on the fpc wiki:
https://wiki.freepascal.org/Cross_compiling#From_win64_to_win32

The link to SF from the Wiki got me to SF and I could download the cross exe I needed.

But when I try to run it, Windows pops up a "Windows protected your PC" message:

"Microsoft Defender SmartScreen prevented an unrecognised app from starting. Running this app might put your PC at risk."

There is a button "Don't run" and a link to more info that displays:

"Application:
lazarus-2.2.4-fpc-3.2.2-cross-i386-win32-win64.exe Publisher:
Unknown publisher"

Now another button "Run anyway" is shown, so I did that and the install seemed to work...

As described in the Wiki I selected to install into the same folder as I had installed Lazarus 2.2.4 initially.

Then opened Lazarus 2.2.4 with my project and changed project options as follows:

Compiler_Options/Config_and_Target/Target OS(-T): Win32

Everything else left as-is.

Now when I OK this, Lazarus pops up a message saying: --------------------------------------
The current FPC has no config file. It will probably miss some units. Check your installation of fpc.
--------------------------------------

When I hit the OK button another pop-up:
--------------------------------------
The project uses target OS=win32 and CPU=x86_64.
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.
[OK]
---------------------------------------

So I followed the install instructions on the Wiki and wound up in this non-working state...

What steps are missing that I must do?
Why does it not find the correct system.ppu?

I searched the install dir for system.ppu and found two here:

C:\Programs\Lazarus_2.2.4\fpc\3.2.2\units\i386-win32\rtl C:\Programs\Lazarus_2.2.4\fpc\3.2.2\units\x86_64-win64\rtl

What I see is:
in C:\Programs\Lazarus_2.2.4\fpc\3.2.2\bin\ only x86_64-win64 exists

in C:\Programs\Lazarus_2.2.4\fpc\3.2.2\units these dirs exsist: i386-win32
x86_64-win64

in C:\Programs\Lazarus_2.2.4\fpc\3.2.2\fpmkinst these dirs exsist: i386-win32
x86_64-win64

It seems like the cross installer failed to install the cross binaries, why????

I must have done something seriously wrong...

Or could the problem be that Windows Defender has blocked all exe files from being installed?

Bo Berglund Developer in Sweden
Tomas Hajny
to Bo Berglund
Bo Berglund wrote
I tried to add a cross-compiler for Win32 to my existing Lazarus 2.2.4 installation on Windows 10 x64.

.
.

Show quoted text 55 lines
Then opened Lazarus 2.2.4 with my project and changed project options as follows: Compiler_Options/Config_and_Target/Target OS(-T): Win32 Everything else left as-is. Now when I OK this, Lazarus pops up a message saying: -------------------------------------- The current FPC has no config file. It will probably miss some units. Check your installation of fpc. -------------------------------------- When I hit the OK button another pop-up: -------------------------------------- The project uses target OS=win32 and CPU=x86_64. 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. [OK] --------------------------------------- So I followed the install instructions on the Wiki and wound up in this non-working state... What steps are missing that I must do? Why does it not find the correct system.ppu? I searched the install dir for system.ppu and found two here: C:\Programs\Lazarus_2.2.4\fpc\3.2.2\units\i386-win32\rtl C:\Programs\Lazarus_2.2.4\fpc\3.2.2\units\x86_64-win64\rtl What I see is: in C:\Programs\Lazarus_2.2.4\fpc\3.2.2\bin\ only x86_64-win64 exists in C:\Programs\Lazarus_2.2.4\fpc\3.2.2\units these dirs exsist: i386-win32 x86_64-win64 in C:\Programs\Lazarus_2.2.4\fpc\3.2.2\fpmkinst these dirs exsist: i386-win32 x86_64-win64 It seems like the cross installer failed to install the cross binaries, why???? I must have done something seriously wrong... Or could the problem be that Windows Defender has blocked all exe files from being installed?

I don't know how it works with Lazarus (I install FPC using the installer provided with FPC, not the one for Lazarus), but I don't think that this has anything to do with Windows Defender. You missed another step mentioned by Sven, in particular changing the target CPU from x86_64 to i386. If it fails to find system.cpu even after that step, you may need to revisit the configuration file as already suggested in the message to make sure that search path for units (-Fu) references the full target "variable" rather than explicitly the x86_64-win64 directory.

Tomas

Bo Berglund
to Martin Frb
Martin Frb wrote 10 lines
On 23/03/2023 09:25, Bo Berglund via fpc-pascal wrote: > > Then opened Lazarus 2.2.4 with my project and changed project options as > follows: > > Compiler_Options/Config_and_Target/Target OS(-T): Win32 > > Everything else left as-is. You need to change the CPU to i386 too

OK, I thought that the current processor could be used since it can run both types of programs...

Bo Berglund Developer in Sweden
Bo Berglund
to Bo Berglund
Bo Berglund wrote 15 lines
On Thu, 23 Mar 2023 09:47:36 +0100, Martin Frb via fpc-pascal wrote: >On 23/03/2023 09:25, Bo Berglund via fpc-pascal wrote: >> >> Then opened Lazarus 2.2.4 with my project and changed project options as >> follows: >> >> Compiler_Options/Config_and_Target/Target OS(-T): Win32 >> >> Everything else left as-is. >You need to change the CPU to i386 too > OK, I thought that the current processor could be used since it can run both types of programs...

A follow-up question:

Is it possible to configure Lazarus itself to have multiple build modes (Default and win32) such that one does not have to redefine them every time a new project is created?

Right now I have operated on the Project/Options/Compiler_options to set the target as Default or win32. I could create a new build option for win32 along side with the Default where the target system, target cpu and target dir were changed from default to specific.

But these modes are AFAICT specific to this project and so have to be re-created for every new project where the crosscompiler will be used in order to easily switch between them.

Bo Berglund Developer in Sweden
Sven Barth
to Bo Berglund: On Thu, 23 Mar 2023 09:47:36 +0100, Martin Frb via fpc-pascal OK, I thought that the…

Bo Berglund via fpc-pascal schrieb am
Fr., 24. März 2023, 07:38:

Show quoted text 17 lines
On Thu, 23 Mar 2023 09:47:36 +0100, Martin Frb via fpc-pascal wrote: >On 23/03/2023 09:25, Bo Berglund via fpc-pascal wrote: >> >> Then opened Lazarus 2.2.4 with my project and changed project options as >> follows: >> >> Compiler_Options/Config_and_Target/Target OS(-T): Win32 >> >> Everything else left as-is. >You need to change the CPU to i386 too > OK, I thought that the current processor could be used since it can run both types of programs...

That has nothing to do with your current processor. This setting is the *target* architecture and can just as well be ARM, PowerPC, AVR, etc. as well and your processor definitely can't run those outside of emulation. The default setting of this is whatever architecture you installed Lazarus as: when you install 64-bit Lazarus on Windows you'll get x86_64 as default and if you install the 32-bit one it will be the i386. And if in the future you install a ARM64 Lazarus on a ARM64 Windows the default will be aarch64. So if you need a different target platform than your default you have to change that.

Regards,
Sven

Martin Frb
to Bo Berglund: On Thu, 23 Mar 2023 09:47:36 +0100, Martin Frb via fpc-pascal OK, I thought that the…
Bo Berglund wrote 6 lines
On Thu, 23 Mar 2023 09:47:36 +0100, Martin Frb via fpc-pascal wrote: > You need to change the CPU to i386 too OK, I thought that the current processor could be used since it can run both types of programs...

Well no, and probably for several reasons.

1) The compiler only cares about the cpu, you have both, so that would be ok.

2) the units (rtl/fcl) are only prebuild for the exact combination

3) I don't think a 64bit app can open the 32 bit dll/kernel. One app has to be either all 64bit code. Or all 32 bit code. The CPU has to run either in one or the other mode. The same byte sequence of code has different meanings in either mode.