Question

I want to build a command-line tool in Free Pascal for run in a SUSE 9.

This is a production server, and it is hard get approved to install anything apart from this tool.

I code on Mac OS X Leopard and wonder if is possible cross-compile from here to Linux?

The server run on Xeon.

Was it helpful?

Solution

Success! If you install Fink and then say

sudo fink install fpc-i386-linux

it will install Free Pascal and everything you need to cross compile. You will then be able to say

/sw/bin/fpc -Tlinux hw.pas

and get a Linux executable.

OTHER TIPS

Unless there are cross-compilation options I can't find, you're probably out of luck doing it directly from Mac OS X. However, you can get what you want by installing a virtual machine like Parallels or Sun's VirtualBox, installing SUSE on it, and compiling there.

There are now .dmg files of Free Pascal (binary, source, and Lazarus) available for install, so it should be easy to install, open, and compile it. Note, though, that if it links to Linux-specific .so files, that they may need to be installed on Mac OS X, or you will have to change the code not to use them.

FPC can crosscompile pretty well in general. There are limitations though:

  1. Crosscompiling from a non x86/x86_64 architecture to x86/x86_64 won't work. It requires extended, which isn't emulated on other archs. However you seem to use an intel OS X machine (not PPC), so that doesn't apply.
  2. Depending on the libraries used and the nature of the target platforms you might need to have target-libraries on host. (in general: not for windows, but you will have to for *nix/OS X as target)

See also http://www.stack.nl/~marcov/buildfaq.pdf it contains some background on crosscompiling with FPC.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top