Is anyone on the list doing this? If so, how did you set it up?
The information on the FPC wiki and elsewhere in the lists is woefully out of date.
Many thanks, Bruce.

Mailing lists / fpc-pascal / 2011-08
16 messages · 7 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Is anyone on the list doing this? If so, how did you set it up?
The information on the FPC wiki and elsewhere in the lists is woefully out of date.
Many thanks, Bruce.
Bruce Tulloch wroteThe information on the FPC wiki and elsewhere in the lists is woefully out of date.
In general, this is not supported (and personally I've never done it). You have to build an Apple tool chain (assembler, linker) on a Linux host, which is not supported by Apple, and then copy a Mac OS X SDK to your Linux machine. Additionally, for -Xg functionality (in combination with DWARF debug information) the dsymutil program is required, but since it's not open source it is definitely not possible to build it for Linux.
I think your best bet is to google general information about cross-compiling from Linux to Mac OS X. I think there is nothing FPC-specific about it, except for maybe pointing the compiler to the SDK (use the -XR command line parameter for that).
Jonas
Is anyone on the list doing this? If so, how did you set it up? The information on the…
Bruce Tulloch wroteIs anyone on the list doing this? If so, how did you set it up?
If your objective is writing software for Mac OS X without actually having a Mac computer, then I seriously doubt it would work, unless your app is a simple command line program. Mac OS X has a number of particularities.
In general, this is not supported (and personally I've never done it). You have to build…
In our previous episode, Jonas Maebe said:
I did it with 10.4. The trouble is getting the toolchain to run. IIRC Adriaan assisted me with that back then.
Is anyone on the list doing this? If so, how did you set it up? The information on the…
Thanks for the feedback everyone.
I have a Mac on which I can run a native FPC/Lazarus environment for debugging purposes. My goal here is to add a cross compiling build for OS X along side existing Linux and Win32/64 targets so all our OS and CPU targets can be , from what I gather, I can copy the SDK across from my (Leopard) Mac to the Linux build machine and I have found odcctools:
http://svn.macosforge.org/repository/odcctools/trunk/
so I should be able to build the toolchain (as, ld).
I don't need -Xg/dsymutils (because I using this as build system only) and I can add a clause to /etc/fpc.cfg to include the necessary search paths.
I'll give it a go and report back.
-b
So I've got cross-compilation working but I have one last problem.
I can't seem to get fpc to drive the linker to search the SDK path BEFORE the default paths. Specifically, i386-darwin-ld finds
/usr/lib/crt1.o
and NOT
/opt/MacOSX10.5.sdk/usr/lib/crt1.o
despite fpc being passed the option
-k-L/opt/MacOSX10.5.sdk/usr/lib
on the command line. I'm using Free Pascal Compiler version 2.4.2 [2011/06/07] for i386 and the complete command line is:
fpc \
-MDelphi \
-Scagi \
-O3 \
-Tdarwin \
-Pi386 \
-k-L/opt/MacOSX10.5.sdk/usr/lib \
-vew \
-l \
-Fi${BUILD}/i386/darwin/carbon \
-Fl/opt/MacOSX10.5.sdk/usr/lib \
-Fusrc \
-Fu${LAZARUS}/lcl/units/i386-darwin \
-Fu${LAZARUS}/lcl/units/i386-darwin/carbon \
-Fu${LAZARUS}/packager/units/i386-darwin \
-FU${BUILD}/i386/darwin/carbon/ \
-FE${BUILD}/ \
-oProject \
-gw \
-godwarfsets \
-dLCL \
-dLCLcarbon \
Project.lpr
I know it works because if I temporarily rename /usr/lib/crt1.o the linker finds the correct SDK version and links the project properly.
What am I doing wrong that fpc does not appear to put the path
/opt/MacOSX10.5.sdk/usr/lib
ahead of the default paths when calling i386-darwin-ld?
Many thanks, Bruce.
Use -XR/opt/MacOSX10.5.sdk/ and get rid of the -k parameter.
Jonas
So I've got cross-compilation working but I have one last problem. I can't seem to get…
I finally managed to get Intel Mac OS X cross-compilation (from Linux) working well so I thought I'd document what I did for the benefit of others because the info in the wiki is wildly out of date.
I'll update the wiki (if I can) to point to this message.
What you'll need:
[1] an Intel Mac running Leopard or Snow Leopard
[2] the original or retail OSX DVD (for the SDK)
[3] a working linux setup (Debian Squeeze in my case) [4] up to date source for FPC (2.4.x) and Lazarus (0.9.30) [5] the Open Darwin cctools (odcctools)
Once set up, you won't need the Mac to compile your code.
STEP 1: copy the SDK from your Mac.
You need to install XCode from your OSX DVD if you've not already done so and copy the SDK to an appropriate location on your Linux box. I'd recommend MacOSX10.5.sdk but it depends on how far back you want to be compatible. MacOSX10.5.sdk is located in /Developer/SDKs on the Mac.
I put mine at /opt/MacOSX10.5.sdk on my Debian box.
STEP 2: grab odcctools from SVN (I use mercurial, hence the "hg" stuff)
hg clone http://svn.macosforge.org/repository/odcctools/trunk/ odcctools
and build it as
$ cd ~/hg/odcctools && ./extract.sh && cd odcctools
$ CC=gcc-4.4 ./configure --target=i386-darwin \
--prefix=/opt/odcctools --with-sysroot=/opt/MacOSX10.5.sdk
$ make && make installI've specified gcc 4.4 but it should be okay with other versions.
STEP 3: rebuild FPC (my sources are in ~/hg/pascal)
$ cd ~/hg/pascal && hg id -bint
730fd5ffbeb1 16666 fixes_2_4 release_2_4_2
$ make distclean && FPC=ppc386 make crossall crossinstall \ CPU_TARGET=i386 OS_TARGET=darwin \
CROSSBINDIR=/opt/odcctools/bin BINUTILSPREFIX=i386-darwin- \ INSTALL_PREFIX=/opt/cross \
OPT="-gl -gw -godwarfsets -XX -CX -Xd -Fl/opt/MacOSX10.5.sdk/usr/lib"
Note that the options (OPT) as shown are vital, especially -gw.
STEP 4: add a darwin (cross-compile) clause to /etc/fpc.cfg
#IFDEF darwin
-Fu/opt/cross/lib/fpc/$fpcversion/units/i386-darwin/ -Fu/opt/cross/lib/fpc/$fpcversion/units/i386-darwin/* -Fu/opt/cross/lib/fpc/$fpcversion/units/i386-darwin/rtl -FD/opt/odcctools/bin
#ENDIF
STEP 5: build the Carbon LCL (in Lazarus)
Be sure to specify the Darwin OS target, i386 CPU target and, most importantly, add the -gw option. Perform a Clean+Build of the LCL and the Package Registration.
You should now be able to use Lazarus in Linux to build for Mac OS X.
There are two more gotcha's when cross-compiling to OS X:
First, be sure to specify the -gw in your projects to avoid problems reported in (the unfixable) FPC bug #12001.
Second, be sure to specify the -XR option pointing to your SDK root, in my case -XR/opt/MacOSX10.5.sdk, or the Darwin linker will try to link to the wrong startup object (/usr/lib/crt1.o).
I hope this information saves the next person to try to set this up a lot of time :-)
Cheers, Bruce.
<snip>
Cheers, Bruce.
Bruce,
Thanks for your post. I've taken the liberty to start the wiki page as I'm trying it out.
See
http://wiki.lazarus.freepascal.org/Cross_compiling_OSX_on_Linux
Regards,
Reinier
Brilliant, thanks Reinier, it looks good. Cheers, Bruce.
My pleasure - though I haven't finished yet & may run into things.
It seems you're setting up a 32 bit environment. Both my Linux (Debian) and OSX machine are 64 bit - don't know if this will work.
Anyway, I'll get back on the list if I have problems...
Reinier
Bruce Tulloch wroteBrilliant, thanks Reinier, it looks good. Cheers, Bruce. On 08/08/11 23:03, Reinier Olislagers wrote: > http://wiki.lazarus.freepascal.org/Cross_compiling_OSX_on_Linux
Reinier Olislagers wroteMy pleasure - though I haven't finished yet& may run into things. It seems you're setting up a 32 bit environment. Both my Linux (Debian) and OSX machine are 64 bit - don't know if this will work.
I've just tried to follow the guide, but seem to run into the same problem as many other apparently also do:
At global scope:
cc1plus: warning: unrecognized command line option "-Wno-long-doubl
From what I can read on the web this is somehow related to 64-bit vs. 32-bit crosscompile, but I'm not sure how to solve it.
The following resources are an interesting read, but didn't really seem to get me any further.
http://code.google.com/p/iphone-dev/issues/detail?id=212#makechanges http://code.google.com/p/iphone-dev/issues/detail?id=14
Neither of the CFLAGS/LDFLAGS options helped me, perhaps someone have done this succesfully on a Ubuntu 10.04 x86_64 like my system.
Kind regards,
Torsten Bonde Christiansen
I've put this on the wiki, don't know if it helps
On 64 bit Linux environments, fpc mailing list users have problems. Perhaps this
[http://stackoverflow.com/questions/3024255/building-odcctools-in-a-64-bit-os StackOverflow question and answer] can help: in the configure step, you'd apparently need to set
CC="gcc -m32" CXX="g++ -m32" ./configure blah blah blah
My pleasure - though I haven't finished yet & may run into things. It seems you're…
Indeed. I have retained a 32 bit system for my main development host for the time being due to issues such as this (not that I knew of this particular problem). I'll be interested to see what solutions you find work as I do plan to migrate to 64 bits soon. Good to know what I'm up against. FWIW, the cross-compiled bundle generated by my new setup does appear to run okay on a 64-bit Mac -b
I've put this on the wiki, don't know if it helps On 64 bit Linux environments, fpc…
You may also put a note that there exists a launchpad ppa for ubuntu, then you don't need to compile the binutils yourself (which evidently can be a pain in the ...).
https://launchpad.net/~flosoft/+archive/cross-apple <https://launchpad.net/%7Eflosoft/+archive/cross-apple>
Btw. I got the compilation working on a Ubuntu 11.04 64-bit (within a VM), but since my main desktop still runs 10.04 I cannot use the ppa.
Kind regards,
Torsten Bonde Christiansen.
Thanks for the hints, but feel free to write it up yourself; I use Debian, not Ubuntu & haven't tried it...
Regards,
Reinier