Cross Compile For Mac Os On Linux

  1. Cross Compile Linux Kernel Module
  2. Cross Compile For Mac Os On Linux Operating System

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.

  1. Cross-compiling on windows for linux free download. Mpv-i686-cross-compiling-MinGW32-Doc This project aims at setting up a MinGW-w64 Toolchain on a pure Linux-32 Bits system to cross-compil. Mac OS X or Linux. Tor Browser enables you to use Tor on Windows.
  2. @jcoffland No, the other way around. It's for building OS X applications on Linux. 'Cross-Compiling on Linux for Mac OS X 10.3 - 10.5' (emphasis added). Note that this answer is very old by now (almost 7 years old, yikes!) and the later answers below have more up to date information.
  • 1Cross compiling for macOS on Linux

Cross compiling for macOS on Linux

Requirements

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)

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
Linux

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

Source

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.freepascal.org/index.php?title=Cross_compiling_OSX_on_Linux&oldid=129917'

Here’s how to create your own, shiny ARM gcc cross-compile toolchain for your Mac. A cross-compile toolchain enables to compile code for a different hardware architecture than the development system. We will be using the Intel/macOS to generate ARM/Linux (Cortex-Axx CPUs) or ARM/bare-metal (Cortex-Mxx Microcontrollers) code. Since the ARM architecture is omnipresent these days in UAV work, this is kind of handy to have working. Trivial to do on Linux as a host system, but our trusty Mac needs some special treatment.

The tool to use is crosstool-ng, which is designed to compile the gcc toolchain for various architectures. The main audience for the tool is Linux, but it works fine on the Mac with a few tricks. There are other sources of information on this topic, but they deal with older versions of macOS and crosstool-ng

[1][2], so here is an update that works on macOS Sierra with the latest crosstool-ng version. Those other websites are still a good source of information, and well worth visiting in the process. Most of the workarounds listed on these pages are no longer required, but at the time of writing a small number of new hiccups need to be considered.Cross

In this tutorial I am using places and paths that I find logical. These can be changed to any other location as desired, of course.

Step 1:

You need X-Code or the command line tools installed to provide build tools on macOS. Nothing that follows will work without it.

Step 2:

Some of the macOS build tools are not equivalent to the GNU/Linux versions. Building a beast like gcc, however, requires those extra functionalities. The package manager Homebrew can be used to install those tools quite easily. Other methods might work as well but have not been tested.

Note: Homebrew contains a formula to install crosstool-ng 1.22. This is outdated and does not work on macOS at the time of writing. So we need to build the tool from the git master for now.

So you need to install Homebrew, which is quite easy. Then install the following packages:

  • autoconf
  • automake
  • libtool
  • help2man
  • coreutils
  • binutils
  • wget
  • gnu-sed
  • gawk
  • libelf
  • make
  • grep

Some of these tools have their equivalent in macOS, so Homebrew installs them with a prefix g, so make becomes gmake and so on. Crosstool-ng is set up nicely to find these alternate versions for you during building. However in the current version (Feb. 2017) is one remaining bug that requires this knowledge.

Step 3:

gcc is a Linux tool and Linux uses case sensitive file systems by default. The Mac does not. So trying to build gcc on the standard Mac disk will inevitably fail. So we need to create a case sensitive disk somehow. Luckily, this is actually quite easy with disk utility. Check out [1] on how to do that. Basically, you want to create a sparse disk image with case sensitive file system somewhere on your disk. Be aware that disk utility actually changes the file system properties as you set the options, so make sure that it is set to case sensitive file system before creating the image.

Step 4:

Create a directory to build crosstools-ng. This can be anywhere on the Mac disk, or in the newly created disk image. Crosstool-ng does not require a case sensitive file system. The clone the git repository into this directory

This creates the directory crosstool-ng, containing the source code. Enter that folder and issue

to generate the configuration scripts. Then we will need to decide where we want to install the crosstool executable. I find it sensible to install it into the build disk image to have it all in one spot. To do that, issue

where I choose PATH_TO_INSTALL_DIR to be /Volumes/ct-ng/ct-ng in the build disk image. This will make and install crosstool-ng in that directory. Any errors will indicate that some of the previous instructions did not succeed. Checking the output of the configuration step might show that some of the GNU/Linux tools were not recognised correctly. You’ll need to verify the Homebrew installation of those tools in this case. If all went well, there should be a working version of crosstool-ng in the INSTALL_DIR.

Cross Compile Linux Kernel Module

Step 5:

To try it out, navigate to that directory and issue

to generate the configuration for one of the per-defined builds as a test case. Then

to enter the build configuration menu. This is the same as used for the Linux kernel. In there, we need to change the default locations of the download- and output directories to point into the case sensitive disk image (the download directory doesn’t need to be there but again, it keeps things organised. Then issue

to build the toolchain. (The ulimit command increases the number of open files allowed, otherwise the build will fail just before the end…)

This will fail immediately, but no worries, the information printed will allow us to fix the problem. As mentioned before, some of the tools installed by Homebrew have the prefix g. And this is the bug in crosstools, where in one file this is not set correctly. Everywhere else it is, so do not try to rename to tool (sed), but make a small change in one of the source files of crosstool. This might get fixed soon as there is an issue open on Github for this. But for now, we need to go into the file printed in the error message (/scripts/functions) and change the broken command (line number given in the error msg) from sed to gsed. Then save the file and try the build again. All should be working fine now. The build will take 40 minutes or so. Once done, there should be a ARM-gcc toolchain in the x-tools directory.

Update [27/02/2017]: This problem appears to be fixed, at least based on my limited testing over the past few days.

Step 6:

To use the toolchain, set the compiler path to

and use the gcc command

Cross Compile For Mac Os On Linux Operating System

to compile the code.

This covered just the basic procedure. When it all works, the toolchain can be configured more specifically to the hardware target using the menuconfig system. This might be the topic of another article.