I'm trying to cross-compile on Ubuntu 9.10 x86_64 for i386. Here's what I've done so far:
I got FPC from the fixes_2_4 branch in SVN and did make/make install. I used samplecfg to generate /etc/fpc/fpc.cfg. I followed the wiki (http://wiki.lazarus.freepascal.org/Cross_compiling#To_Linux) and did the steps listed there, including creating the i386-linux-ld and i386-linux-ls scripts in /usr/bin and compiling for the i386 target, so I ended up with a ppc386. At this point I could do a simple "hello world" program which would generate a 64-bit binary if i selected x86_64 for the target in lazarus under "Compiler Options | Code" and a 32-bit binary if i selected i386 as the target. So far so good. I then tried to compile something a bit more complicated (not that much more, though: I just tried to include "cthreads") and I got an error about crti.so not being found: /usr/bin/ld: skipping incompatible /usr/lib/crti.o when searching for /usr/lib/crti.o /usr/bin/ld: cannot find /usr/lib/crti.o build.lpr(16,1) Error: Error while linking As the Wiki is extremely vague as to what to do for fpc.cfg (Sorry, but "Edit your /etc/fpc.cfg file if needed" is not very useful), I did change this line: #-Fl/lib;/usr/lib to -Fl/lib;/usr/lib;-Fl/lib32;/usr/lib32 However, to no avail. However, I did discover that /usr/lib32 doesn't even have crti.o, so a little more investigation made me realize I needed to install the "libc6-dev-i386" package, after which I did, in fact, have that file. However, I'm still unable to compile a 32-bit executable that includes "cthreads" in its uses clause. ld still complains about not being able to find crti.o, despite my having added /usr/lib32 to the -Fl line of my fpc.cfg. I do have this in my fpc.cfg: ============================== # set binutils prefix #IFNDEF CPUI386 #IFNDEF CPUAMD64 #DEFINE NEEDCROSSBINUTILS #ENDIF #ENDIF #IFNDEF linux #DEFINE NEEDCROSSBINUTILS #ENDIF #IFDEF FPC_CROSSCOMPILING #IFDEF NEEDCROSSBINUTILS -XP$fpctarget- #ENDIF NEEDCROSSBINUTILS #ENDIF ============================== but I don't know if that's correct or whatever, that's just what samplecfg generated. Observe: compiling for 64-bit ============================== $ /usr/local/bin/fpc -MObjFPC -Scgi -O1 -gl -vewnhi -l -Fu. -obuild build.lpr Hint: Start of reading config file /etc/fpc.cfg Hint: End of reading config file /etc/fpc.cfg Free Pascal Compiler version 2.3.1 [2009/11/02] for x86_64 Copyright (c) 1993-2009 by Florian Klaempfl Target OS: Linux for x86-64 Compiling build.lpr Linking build ld here i am ld.real: warning: link.res contains output sections; did you forget -T? 17 lines compiled, 0.2 sec 2 hint(s) issued ============================== attempting to compile for 32-bit ============================== $ /usr/local/bin/fpc -Pi386 -MObjFPC -Scgi -O1 -gl -vewnhi -l -Fu. -obuild build.lpr Hint: Start of reading config file /etc/fpc.cfg Hint: End of reading config file /etc/fpc.cfg Free Pascal Compiler version 2.3.1 [2009/11/02] for i386 Copyright (c) 1993-2009 by Florian Klaempfl Target OS: Linux for i386 Compiling build.lpr Linking build ld: warning: link.res contains output sections; did you forget -T? ld: skipping incompatible /usr/lib/crti.o when searching for /usr/lib/crti.o ld: cannot find /usr/lib/crti.o build.lpr(16,1) Error: Error while linking build.lpr(16,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled) ============================== I sort of think that /usr/bin/i386-linux-ld isn't being called. I added an "echo here I am" sort of line to that bash script, and I never see that echo happen. I'm sure there's some magic I need to do in my fpc.cfg file, but I'm having a hard time finding specifically what it is. I'd really like to be able to compile for x86_64 and i386 in the same development environment simply by selecting a different target from the Lazarus UI and have it "just work." If anyone can offer assistance, I'd surely appreciate it. -SG -- This email is fiction. Any resemblance to actual events or persons living or dead is purely coincidental. Seth Grover sethdgrover[at]gmail[dot]com _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal