Linux Cross Compiler For Mac Os X

  



  • 1Cross compiling for macOS on Linux

Cross compiling for macOS on Linux

  1. Eclipse C Compiler. With Eclipse you get advance functionality for programming in C, C on an.
  2. We link to the system libusb on Mac OS X and Linux. On Windows depending on the bit depth we can link to libusb-1.0-32.dll.a or libusb-1.0-64.dll.a.Remember that.a-file can be renamed, but the application will still depend on libusb-1.0.dll.We take parameters for libusb through the system utility pkgconfig in Linux. We include all necessary system libraries and icons in addition to libusb.

Requirements

Cross-compiler for Linux on Mac OS X? Ask Question Asked 9 years, 2 months ago. Active 1 year, 2 months ago. Viewed 11k times 6. I've been reading lots of documents on the internet about creating a cross compiler for linux on mac os x but can't seam to get any to work. Building cross-compiler toolchains is a time-consuming process. This site provides pre-built cross-compiler toolchains for Apple Mac OS X (i.e. Darwin), targetting the Linux operating system on common architectures, currently arm and aarch64.In other words, compile code for ARM/Linux on your Mac. Darwin/Mac OS X Cross-Compiler for Linux. This is a set of tools for creating a Linux-based distcc node for compiling Mac OS X software. It is comparable to XCode 2.2.1 (GCC 4.0.1 build 5250,.

What you'll need:

  • an Intel Mac running Leopard, Snow Leopard, or Lion
  • Xcode installed on your Mac or the original or retail operating system DVD (for the SDK)
  • a working Linux setup (tested with Debian Squeeze)
  • up to date source for FPC (tested with 2.4.x) and Lazarus (tested with 0.9.30)
  • the Open Darwin cctools (odcctools)
Compiler

Warning: These instructions are for i386 Linux; trying this on x64 Linux has failed. Update 2013-12-13: cross compiling from Linux for macOS no longer works at all for 10.8 and above. The compiler works fine but viable linker tools (cctools for linux) are not available for Linux anymore. Please adjust instructions if you find a solution for this. The cctools are available in Arch Linux.

STEP 1: copy the SDK from your Mac

You need to install Xcode from your operating system DVD if you've not already done so and copy the SDK to an appropriate location on your Linux box.

I'd recommend Leopard 10.5.sdk (compatible with Leopard) but it depends on how far back you want to be compatible. The 10.5.sdk is located in /Developer/SDKs on the Mac.I put mine at /opt/Mac/ on my Debian box. Example using ssh from your Linux box to copy over the files:

STEP 2: grab odcctools from SVN

Odcctools apparantly provide binutils for OSX/Darwin.

On 64 bit Linux environments, fpc mailing list users have problems with this step. Perhaps this StackOverflow question and answer can help: in the configure step, you'd apparently need to setCC='gcc -m32' CXX='g++ -m32' ./configure blah blah blah

and build it as

This installs the tools in /opt/odcctools.I've specified gcc 4.4 but it should be okay with other versions.

STEP 3: rebuild FPC

(my sources are in ~/hg/pascal)

Note that the options (OPT) as shown are vital, especially -gw.

STEP 4: configure fpc.cfg

Add a darwin (cross-compile) clause to /etc/fpc.cfg:

STEP 5: build the Carbon LCL

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 macOS.

Gotcha's

There are two more gotcha's when cross-compiling to macOS:

  • Be sure to specify the -gw in your projects to avoid problems
Online linux compiler

reported in (the unfixable) FPC bug #12001.

  • Be sure to specify the -XR option pointing to your SDK root (e.g. -XR/opt/Mac/Leopard10.5.sdk), or the Darwin linker will try to link to the wrong startup object (/usr/lib/crt1.o).

C++ Compiler For Linux

Source

Compiler

Fpc Mailing list 6 August 2011 post by Bruce titled 'Re: Cross Compiling from Linux to Leopard 10.5 or Snow Leopard 10.6 target. How? [SOLVED]'Adapted by BigChimp

Older instructions

This section was taken from the general Cross compiling page and may still be of interest:

  • First you need the binutils for the platform you want to compile to. Download odcctools from this site (use the cvs version) and follow their instructions for installing. http://www.opendarwin.org/projects/odcctools/
  • you need to create a fake root dir like: $HOME/darwinroot copy at least the /System and /Frameworks and /usr directories (you may have to copy more than this) from your Apple or Darwin computer to $HOME/darwinroot
  • now that you have these files make a folder in $HOME/darwinroot called cross. where ever you installed the odcctools you need to make links for the cross tools to be more fpc friendly. there are a bunch of files from odcc tools called powerpc-apple-darwin-* you need to make links (or rename them) so powerpc-apple-darwin-ld becomes powerpc-darwin-ld, do the same for *-ar and *-as.
  • now you are ready to crosscompile fpc. basically you need to have the fpc source and have a terminal open there.

type:

type (iirc):

if that succeded you can install it to whereever you want with:

now copy the file ./compiler/ppccross somewhere you will be able to find it as it's the compiler you'll need to build powerpc programs

  • configure your /etc/fpc.cfg file.

add a section like this:

whenever you want to crosscompile you have to have ppccross and the symlinks to powerpc-darwin-* in the PATHand you should be able to just do ppccross someprogie.pas and it will create a darwin executable.

I may have missed some things (or most everything) as it's been a while since I did this.

Retrieved from 'https://wiki.lazarus.freepascal.org/index.php?title=Cross_compiling_OSX_on_Linux&oldid=129917'
I have a console program that I wrote and use on my windows and Linux PCs. However, I need to give a copy of the program to a colleague that only has a Mac. I see that there is an unofficial OS X version of Freebasic, but I don't have a Mac to run it on.
I need advice on the best way I can cross-compile so the program will run on the MAC.

Linux Cross Compiler For Mac Os X Versions


Or is there a stock-standard scripting language I could re-write my programs in? (ie something where I wouldn't have to explain to my colleague how to find and install something like Perl or Python.) I would have to write the script on my Linux box, but it would need to run on the Mac.
Ideas?
Thanks,

Online Linux Compiler

David