[fpc-pascal] Linker fails cross compiling from Linux to Mac.

Bruce Tulloch pascal at causal.com
Tue Jan 8 10:49:19 CET 2013


I had a working Debian Squeeze to Mac OSX Snow Leopard cross-
compilation system working. It's documented here:

http://wiki.freepascal.org/Cross_compiling_OSX_on_Linux

Unfortunately the method described on that page is now broken.

The problem linking for OSX on a Linux no longer works for me.

It produces errors like these:

i386-darwin-ld: MacOSX10.6.sdk/usr/lib/libiconv.dylib load command 5
unknown cmd field
i386-darwin-ld: MacOSX10.6.sdk/usr/lib/libobjc.dylib load command 7
unknown cmd field
i386-darwin-ld: MacOSX10.6.sdk/usr/lib/libc.dylib load command 5
unknown cmd field
i386-darwin-ld:
MacOSX10.6.sdk/System/Library/Frameworks/Carbon.framework/Carbon load
command 4 unknown cmd field
i386-darwin-ld:
MacOSX10.6.sdk/System/Library/Frameworks/Cocoa.framework/Cocoa load
command 4 unknown cmd field
i386-darwin-ld:
MacOSX10.6.sdk/System/Library/Frameworks/OpenGL.framework/OpenGL load
command 5 unknown cmd field
i386-darwin-ld:
MacOSX10.6.sdk/System/Library/Frameworks/Foundation.framework/Foundation
load command 6 unknown cmd field

Here's what I'm using:

1) FPC 2.6.2 rc1 (and I've tried 2.6.0 as well).
2) Apple's cctools 809 release suitably patched.
3) A Debian Wheezy Linux host.

The cctools-809 source comes from:

http://www.opensource.apple.com/tarballs/cctools/cctools-809.tar.gz

The patch applied to make it buildable for Linux is:

https://github.com/mingwandroid/xchain/blob/master/patches/cctools-809-nondarwin.patch

plus a few tweaks of my own to fix some build bugs.

It's built against MacOSX10.6.sdk (I've tried MacOSX10.5.sdk too) for
32 bit (-m32) builds (64 bit is not supported). FPC, FCL, LCL et al
are all built against the same SDK. Compilation works just but linking
fails as shown above.

I've tried various combination of compilation switches but nothing
seems to allow the link to succeed.

Does anyone have a clue why this might be failing? I seems like I'm on
the brink of success if only I can work out why these errors are
occurring.

The most obvious thought is that not all objects were built against
the same revision of the SDK but I can confirm they are. The missing
command codes are (from MacOSX10.6.sdk/usr/include/mach-o/loader.h):

#define	LC_THREAD      0x4 /* thread */
#define	LC_UNIXTHREAD  0x5 /* unix thread (includes a stack) */
#define	LC_LOADFVMLIB  0x6 /* load a specified fixed VM shared library */
#define	LC_IDFVMLIB    0x7 /* fixed VM shared library identification */

I will give up on this if no one has any ideas and the wiki needs to
be updated to report that cross-compilation from Linux to Mac is no
longer possible but I'm willing to give it some more work based on
pointers anyone can suggest.

Failing that I will revert to a native Mac system but I'd really like
to have cross-compilation working if possible.

Any suggestions?

Bruce



More information about the fpc-pascal mailing list