[solved] Crosscompiling Mint 17.3 --> Win32/64 lazarus / 1-Linux ---------------------------------------------------------------------- Kralle · 2016-02-14 13:46 Hello, under Linux Mint 17.3 i installed FP 3.0.0 and Lazarus 1.6RC2 with this Script: Quote#!/bin/bash # # run in your HOME-directory with: sudo sh getlaz.sh  (HR) # # (C)by: Michael Van Canneyt (michael@freepascal.org) # # Release from: 2016-01-30  (HR) # additional comments from: Heiko Rompel (HR) ######################################################## # Some variables. Set this to whatever you want ######################################################## # # Where to download/install everything ? (below home directory) # INSTALLDIR=fpc # # Which FPC version to use ? # VERSION=3.0.0 CPUARCH=`uname -p` # # Install FPC/Lazarus as root ? (YES or NO) # USEROOT=YES # # Which lazarus version ? # set either tag or branch variable. # If neither is set, trunk is used. # When lazarus 1.6 is out, this becomes lazarus_1_6 # # A newer RC is out (HR) TAG=lazarus_1_6_RC2/ BRANCH= ######################################################### # No variables after this point. ######################################################### # # Install preliminaries. This must be done as root. # sudo apt-get install subversion make binutils gdb gcc libgtk2.0-dev # # Check if the rest must be done as root. # if [ "$USEROOT" = YES ]; then   SUDO=sudo fi # ###################################################################### # # Get and install FPC. ###################################################################### # # # Create installation directory # mkdir ~/$INSTALLDIR cd ~/$INSTALLDIR # # Fetch the necessary files for FPC. # wget ftp://ftpmaster.freepascal.org/pub/fpc/dist/$VERSION/source/fpc- $VERSION.source.tar.gz wget ftp://ftpmaster.freepascal.org/pub/fpc/dist/$VERSION/$CPUARCH- linux/fpc-$VERSION.$CPUARCH-linux.tar # # extract installer. # tar xvf fpc-3.0.0.$CPUARCH-linux.tar cd fpc-3.0.0.$CPUARCH-linux # # Install FPC (possibly as root) # $SUDO sh ./install.sh # # Extract sources. # cd ~ tar xvzf $INSTALLDIR/fpc-$VERSION.source.tar.gz cd ~/$INSTALLDIR # ###################################################################### # # Get and install Lazarus ###################################################################### # # # Determine SVN url # BASEURL=http://svn.freepascal.org/svn/lazarus/ # if [ ! -z "$TAG" ]; then   SVNURL=$BASEURL/tags/$TAG else   if [ ! -z "$BRANCH" ]; then     SVNURL=$BASEURL/branches/$BRANCH   else     SVNURL=$BASEURL/trunk   fi fi # # Check out sources # svn co $SVNURL lazarus # # Build the IDE # cd lazarus make bigide # # Install lazarus (possibly as root) # $SUDO make install # # That's all folks ! # But what must i do then? http://wiki.lazarus.freepascal.org/Cross_compiling_for_Win32_under_Lin ux the Information doesn't work. At the German Lazarus-Forum in this Thread: http://www.lazarusforum.de/viewtopic.php?f=16&t=9411 i post the thinks a tested, but nothing works. Is here somebody who used Linux-Lazarus to create Win32/64-Code? If yes, please help me. ---------------------------------------------------------------------- Leledumbo · 2016-02-14 14:48 Quote from: Kralle on February 14, 2016, 02:46:23 pmthe Information doesn't work. Describe "doesn't work". What steps have you done? What output do you get? Where are you stuck? Have you read and understood the generic article that you must read prior to reading above article? ---------------------------------------------------------------------- Kralle · 2016-02-14 15:27 Hello, after install FPC and Lazarus, i started Lazarus an press F9. The default "program" will compiled and run. Then i take a snapshot (VMware Workstation (only for testing)). After this i do this: Quote Newer FPCs - 2.1.1 and newer If you are compiling a 2.1.1 or newer version of FPC you can just do: $ make all OS_TARGET=win32 CPU_TARGET=i386 and then $ su -c "make crossinstall OS_TARGET=win32 CPU_TARGET=i386" Note-icon.png Note: make crossinstall by default installs all files in /usr/local/lib/fpc/$fpcversion/units directory that's why you will need to add to /etc/fpc.cfg file new search path -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget. Other option is to use INSTALL_PREFIX=/usr while performing crossinstall in this case you will not need to change anything in /etc/fpv.cfg file because all will be instaled in /usr/lib/fpc/$fpcversion/units witch is alredy there Note-icon.png Note: To build for win64 the make command is: make all OS_TARGET=win64 CPU_TARGET=x86_64 The reason for this simplicity is the internal linker included in this version of fpc. After this i do this: overrides.jpg then i switch the Buildmode to "win32" and press F9 again. But i become this win_error.jpg And now? Greeting Heiko ---------------------------------------------------------------------- Cyrax · 2016-02-14 16:02 Did you edit /etc/fpc.cfg to include new paths for win32 units as requested? ---------------------------------------------------------------------- Leledumbo · 2016-02-14 16:07 From the 2nd screenshot, it's clear that your cross compiler toolchain is not built / configured well. Where did you execute `make all OS_TARGET=win32 CPU_TARGET=i386` and `su -c "make crossinstall OS_TARGET=win32 CPU_TARGET=i386"` and what did it output? Are both successful? Confirm by locating /usr/local/lib/fpc exists and not empty, at least there should be ppcross386 and units/i386-win32 (which contains a bunch of directories for each package containing their respective compiled units) thereHave you done what's told in the "Note" part? Modify -Fu in fpc.cfg if you don't get itHas the symlink to ppcross386 above been created somewhere in PATH? Preferrably in the same place as fpc binary ---------------------------------------------------------------------- Kralle · 2016-02-14 17:16 Hello, thank you for your help. Quote from: LeledumboWhere did you execute `make all OS_TARGET=win32 CPU_TARGET=i386` and `su -c "make crossinstall OS_TARGET=win32 CPU_TARGET=i386"` I do this in "/home/laz-user/fpc-3.0.0" (laz- user@laz-book ~/fpc-3.0.0) Quote from: Leledumboand what did it output? Results for the first one (without sudo): result1.txt Results for the first one (with sudo): result1_sudo.txt Result for the second one: result2.txt (to many Words for direct quote) Quote from: LeledumboAre both successful?I think: yes. Quote from: LeledumboConfirm by locating /usr/local/lib/fpc exists and not empty, ready Quote from: Leledumboat least there should be ppcross386 and units/i386-win32 (which contains a bunch of directories for each package containing their respective compiled units) there yes Quote from: LeledumboHave you done what's told in the "Note" part? No  Quote from: LeledumboModify -Fu in fpc.cfg if you don't get it if found the write-protected "fpc.cfg" and found this: Quote# searchpath for units and other system dependent things -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/* -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl #ifdef cpui8086 -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch- $fpcmemorymodel -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch- $fpcmemorymodel/* -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch- $fpcmemorymodel/rtl #endif #IFDEF FPCAPACHE_1_3 -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd13/ #ELSE #IFDEF FPCAPACHE_2_0 -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd20 #ELSE -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd22 #ENDIF #ENDIF # searchpath for fppkg user-specific packages -Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/* Is there something to do for me?? Quote from: LeledumboHas the symlink to ppcross386 above been created somewhere in PATH? Preferrably in the same place as fpc binary Sorry, i didn't understand this? (i'm a linux newbie) Greetings from germany Heiko ---------------------------------------------------------------------- Leledumbo · 2016-02-14 17:29 OK, both building and installation success, though it's a little weird you don't have write permission in a folder inside your home directory. Quote from: Kralle on February 14, 2016, 06:16:24 pmif found the write-protected "fpc.cfg" and found this: ... Is there something to do for me?? Yes, read the note. The first sentence contains copy-paste-able line that you can write into your fpc.cfg. I suggest making the file writable unless you prefer to always prefixing your editing command with sudo. Quote from: Kralle on February 14, 2016, 06:16:24 pmQuote from: LeledumboHas the symlink to ppcross386 above been created somewhere in PATH? Preferrably in the same place as fpc binary Sorry, i didn't understand this? (i'm a linux newbie) I assume your host fpc is in /usr/bin, so it's: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ sudo ln -s /usr/local/lib/fpc/ppcross386 /usr/bin/Verify by calling fpc -Pi386 -Twin32, fpc should be able to execute ppcross386 and display the help output. ---------------------------------------------------------------------- Kralle · 2016-02-14 18:19 Hello, Quote from: LeledumboYes, read the note. The first sentence contains copy-paste-able line that you can write into your fpc.cfg. I suggest making the file writable unless you prefer to always prefixing your editing command with sudo. okay, i do this. Quote from: LeledumboI assume your host fpc is in /usr/bin, so it's: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ sudo ln -s /usr/local/lib/fpc/ppcross386 /usr/bin/okay, i do this. Quote from: LeledumboVerify by calling fpc -Pi386 -Twin32, fpc should be able to execute ppcross386 and display the help output. This is the output  Quotelaz-user@laz-book /usr/local/lib/fpc/3.0.0 $ fpc -Pi386 -Twin32 Free Pascal Compiler version 3.0.0 [2016/02/14] for i386 Copyright (c) 1993-2015 by Florian Klaempfl and others Fatal: No source file name in command line Fatal: Compilation aborted Error: /usr/bin/ppcross386 returned an error exitcode laz-user@laz-book /usr/local/lib/fpc/3.0.0 $ After this i do a restart from linux, but the result is the same. If i start Lazarus and switch to "Win32" an press F9, the result is the same as in my first post. I didn't understand what wrong is. Greeting Heiko ---------------------------------------------------------------------- Leledumbo · 2016-02-14 18:25 Quote from: Kralle on February 14, 2016, 07:19:55 pmThis is the output  Quotelaz-user@laz-book /usr/local/lib/fpc/3.0.0 $ fpc -Pi386 -Twin32 Free Pascal Compiler version 3.0.0 [2016/02/14] for i386 Copyright (c) 1993-2015 by Florian Klaempfl and others Fatal: No source file name in command line Fatal: Compilation aborted Error: /usr/bin/ppcross386 returned an error exitcode laz-user@laz-book /usr/local/lib/fpc/3.0.0 $ That's correct output, I was wrong it shouldn't display the help page. Quote from: Kralle on February 14, 2016, 07:19:55 pmAfter this i do a restart from linux, but the result is the same. No need, neither of the commands change OS related things. It's not Windows where restart might solve problems magically. Quote from: Kralle on February 14, 2016, 07:19:55 pmIf i start Lazarus and switch to "Win32" an press F9, the result is the same as in my first post. I didn't understand what wrong is. Greeting Heiko I just realized, the note was missing two characters. Instead of: -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget you should add: -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/* to fpc.cfg. ---------------------------------------------------------------------- Kralle · 2016-02-14 18:59 Hello, Quote from: LeledumboI just realized, the note was missing two characters. Instead of: -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget you should add: -Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/* to fpc.cfg. okay, i change the line, but i become this: error.jpg. Is there something to do in lazarus for me? Greeting Heiko ---------------------------------------------------------------------- Leledumbo · 2016-02-14 19:03 That's still not right as the compiler can't find unit Windows which should reside in the directory pointed by that -Fu. Confirm the existence of the file in /usr/local/lib/fpc/$fpcversion/units/$fpctarget/rtl/, replace $fpcversion and $fpctarget accordingly, there should be windows.ppu and windows.o. If you're on 64-bit Linux, don't forget to change Target CPU Family to i386. ---------------------------------------------------------------------- Kralle · 2016-02-14 19:10 Hello, Quote from: Leledumbo on February 14, 2016, 08:03:47 pmThat's still not right as the compiler can't find unit Windows which should reside in the directory pointed by that -Fu. Confirm the existence of the file in /usr/local/lib/fpc/$fpcversion/units/$fpctarget/rtl/, replace $fpcversion and $fpctarget accordingly, there should be windows.ppu and windows.o. If you're on 64-bit Linux, don't forget to change Target CPU Family to i386. for today i say:"Thanks." Tomorrow: I will look for the Error again. Good Night. Bye Heiko ---------------------------------------------------------------------- Kralle · 2016-02-16 11:18 Hello, here I am again. Win32 works. But Win64 doesn't.  Where is my mistake? Greeting Heiko ---------------------------------------------------------------------- Leledumbo · 2016-02-16 12:09 Quote from: Kralle on February 16, 2016, 12:18:28 pmWin32 works. But Win64 doesn't.  Where is my mistake? Build the toolchain for win64 as well, the first article already mentioned that. ---------------------------------------------------------------------- Kralle · 2016-02-16 13:16 Hello, Quote from: LeledumboBuild the toolchain for win64 as well, the first article already mentioned that. upps, i forgot this. Now i do this, but i become this error-message: QuoteError: Invalid Compiler: file "usr/local/bin/ppcx64" does not exist. in the directory is a symlink, but it is defined as "faulty". Who do i create a good symlink? Code: [Select]sudo ln -s /usr/local/lib/fpc/3.0.0/ppcx64 /usr/local/bin/ doesnt' work. the symlink is faulty. Greetings Heiko ---------------------------------------------------------------------- bylaardt · 2016-02-16 16:05 Code: [Select]$ sudo ln -l /usr/local/lib/fpc/3.0.0/ppcrossx64 /usr/local/bin be sure to remove old broken links ---------------------------------------------------------------------- Kralle · 2016-02-16 16:56 Hello, Quote from: bylaardt on February 16, 2016, 05:05:05 pmCode: [Select]$ sudo ln -l /usr/local/lib/fpc/3.0.0/ppcrossx64 /usr/local/bin be sure to remove old broken links parameter -l is unknow  source : ppcrossx64 is ok target: must be ppcx64 , because "Error: Fehler: Ungültiger Compiler: file "/usr/local/bin/ppcx64" does not exist" How must i edit the bash line ? If i rename ppcrossx64 to ppcx64 i can create X64-Exe. Greeting Heiko ---------------------------------------------------------------------- bylaardt · 2016-02-16 17:48 sorry, is "-s" (symbolic link) not -l ... Cross compile works with ppcrossx64. it's needless rename this file. ---------------------------------------------------------------------- Kralle · 2016-02-16 17:50 Hello, Quote from: bylaardt on February 16, 2016, 06:48:21 pmsorry, is "-s" (symbolic link) not -l ... Cross compile works with ppcrossx64. it's needless rename this file. at the override section on compiler-commandos / Compiler was this in the editfeld :"/usr/local/bin/ppcx64". i changed it to: "$(CompPath)" and it works with " ppcrossx64". Greeting Heiko ---------------------------------------------------------------------- Kralle · 2016-02-16 18:06 Thanks to all of you. with the infos in this thread, it ist possible to use Lazarus to create Code for Linux, Win32 and Win64. Great. greetings from a happy heiko ---------------------------------------------------------------------- Kralle · 2016-02-21 06:14 Hello, on http://rompelsoft.de/index.php/download/download/20- anleitungen/104-lazarus-crosscompiling you will find a manual with all information from this thread and the information how to use WINE with Lazarus. Bye Heiko