My experiences in compiling from Linux64 for Win64 lazarus / 32-Linux ---------------------------------------------------------------------- Yogi · 2012-07-01 20:32 Hello to all I would like to share my experiences I made the last days when trying to set up compiling my programs with lazarus/fpc from linux to windows-executables. It is relatively easy if You are on Linux with 32 bit and want to compile executables for Win32 It is more complicated on Linux with 64 bit and compile for Win64 Googling about this statet most that it would be not possible at the moment. But I did not give up and found out some interesting things And here is what I have done Code: [Select]Compiling from Linux (i386, x86_64) to Windows with Lazarus The following steps are for SVN-Versions of FPC and Lazarus (There are some slightly differences if You are on 32bit or 64bit) 1. Prepare FPC (as root)    Go to the directory where Your SVN-Version of FPC resides    and do this:    make distclean   # erase everything that might disturb us    svn update       # do the update via svn    make all install # build a new compiler and install it                     # together with the correspondending units                     # ! this compiler is already able to compile                     # ! for windows with the SAME CPU                     # ! it lacks only the correspondending                     # ! units in the installation    make all install OS_TARGET=win32   # on linux with i386       # or !!! don't do both, it won't work    make all install OS_TARGET=win64   # on linux with x86_64                     # we now have the units installed we need                     # but we also got some Windows-Executables                     # we dont need, so lets clean up:    make distclean    rm utils/*.exe    rm compiler/utils/*.exe    rm /usr/local/bin/*.exe    rm /usr/local/lib/fpc/"actual svn-fpc-version"/ppc386.exe # if OS_Target was win32       # or    rm /usr/local/lib/fpc/"actual svn-fpc-version"/ppcx64.exe  # if OS_Target was x86_64 2. Using this in Lazarus    -> Tools -> Options       Set Compiler-Path to the obove created compiler    -> Project -> Project-Options -> Compiler-Options -> Paths       Make sure at "TargetFilename" the "Apply conventions" is checked    -> Project -> Project-Options -> Compiler-Options -> Build-Modes       Set LCLWidgetType          when compiling for windows use "win32"          what to use on linux You should know ;-)    -> Project -> Project-Options -> Compiler-Options -> Code- Generation       Change Target-OS          on 32bit use Win32, on 64bit use Win64 On a 32bit System thats all Start the compiling for windows with Ctrl-F9 the first time all necessary parts of the lcl and their packages will be also recompiled automatically. Copy the resulting EXE to windows and run it there. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! On a 64bit System it is not so easy !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! You can try to compile. As long as You are not using resources in Your program it will work, but as soon as resources are used You will end up with the following error:    can not run "x86_64-win64-gorc" . . . This is because on 64bit fpc with target windows does not use windres, it tries to find GoRC which is not available for linux So no compiling to Win64 ? It is possible with the following workaround: First You have to look for the executable GoRC.exe for Windows You now will ask what to do with a Windwos-Executable on Linux; its quite simple, You can run it in "Wine" And here are the steps to do this 1. Get GoRC.exe for Windows    ( I took it from my FPC/Lazarus installation on WIN-7) 2. If not already done install wine from repo 3. Copy GoRC.exe to /usr/local/bin/x_gorc.exe 4. Create the following script: /usr/local/bin/x86_64-win64-gorc       #!/bin/sh       cmdline="/usr/bin/wine /usr/local/bin/x_gorc.exe"       for par in $@       do         par3=`echo $par | cut -c-4`         if [ "$par3" = "/hom" -o "$par3" = "/usr" ]         then           cmdline="$cmdline z:$par"         else           cmdline="$cmdline $par"         fi       done       $cmdline 5. Make the script executable Now You can also compile executables from Linux64 for Win64 Note: This will only work for Linux32 to Win32 and Linux64 to Win64 Im working on solutions for other combinations and as soon as I have found out how I will share that here too. Also I happy about comments and eventually better solutions. have a nice day Yogi