[Lazarus] Cross-compiling Linux project to Windows from inside IDE
Mattias Gärtner
nc-gaertnma at netcologne.de
Mon Nov 9 14:36:39 CET 2009
Zitat von Graeme Geldenhuys <graeme at mastermaths.co.za>:
> [...]
> Below is a partial layout of fpGUI project directory, to help explain my
> reason for multiple .lpk files - one for each backend (platform).
>
> /home/graemeg/programming/fpgui
> .
> |-lib
> |---i386-linux
> |---i386-win32
> |---x86_64-linux
> |-src
> |---corelib
> |-----gdi
> |-----x11
> |---gui
>
>
> All sub-directories inside 'lib' are created by Lazarus. 'lib' is where
> all compiler unit files end up. eg: *.ppu *.o etc..
>
> The 'src' directory is the tricky one. Here I am not sure if Lazarus
> Packages support what I need - or maybe I can change my code to
> accommodate Lazaurs IDE. Not sure.
You have a custom set of platforms (values: x11, gdi). Just like the
LCL widgetset.
At the moment the LCL widgetset is hard coded into the IDE and
packages can not yet define their own 'platforms' (they will be called
build variables).
So you can not yet easily switch your custom platforms.
Using two different lpk is a good solution.
Of course you can write a designtime package and install an
speedbutton and/or menu item to switch between the packages. If they
have both the same name, a simple open package should be enough.
> [...]
> So how can Lazarus Packages support my requirements? Alternatively, is
> there another way I can restructure my code - but I can't really see how.
>
>
>
>>> 3) Environment Options: Change Compiler path and FPC Source Path.
>>
>> Why? Just choose fpc as compiler and let fpc call the ppcXXX
>> compiler based on the
>> -P parameter.
>
> I have had problems with 'fpc' on my system, so for some reason I only
> have ppcXXX files. I'll try and recompile my FPC again to see if I can
> resolve this issue.
fpc has evolved in the last years.
> The reason for the Source Path change is because I use FPC 2.2.5 to
> compile FPC 2.3.1 (64bit). So for 64bit (linux) work, I mainly use FPC
> 2.3.1 code. And because FPC 64bit executable cannot create a
> cross-compiled FPC 32bit executable, I keep using the 2.2.5 for 32bit
> development. So I used FPC 2.2.5 (32bit linux) to cross-compile a FPC
> 2.2.5 windows 32bit compiler.
You can use the macro $(FPCVer) in the FPC source path of lazarus.
> I did post a question in the fpc-users mailing list as to why 64bit FPC
> cannot create a 32bit FPC, but vice-versa is possible.
Can someone confirm, that the 64 bit ppc can compile 32 bit code?
>>> 4) In my Project Compiler Options dialog, go to Code tab and change
>>> target platform and CPU to 'Windows 32' and 'i386'. Remember, by current
>>> setup is Linux with 64bit FPC.
>>
>> These steps are indeed necessary.
>
> I suppose if the IDE supported Build Modes like MSEide, this would have
> made things much simpler. Simply select Run and then any of the build
> modes you setup in the menu.
Yes, this planned.
I already started the internals. Maybe 50% already works.
>>> 6) If fpGUI code changed, manually run the cross-compile scrip.
>>
>> Why don't you let the IDE recompile the package?
>
> As I explained above. It's a bit more complex, using different units per
> platform and using different include paths per platform. I'll take a
> look now at the printers4lazarus packages you mentioned. Maybe that will
> give me some hints on how I could solve issue (1).
printers4lazarus uses the TargetOS and LCLWidgetType macros.
Mattias
More information about the Lazarus
mailing list