Cross Compile For Linux On Mac

Cross Compile For Linux On Mac

  1. Cross Compile Linux Kernel Module
  2. Cross Compile For Linux On Mac Os
  3. Clang Cross Compile For Linux On Mac
  4. Cross Compile For Linux On Mac Download
  • Cross compilation issues¶. In GCC world, every host/target combination has its own set of binaries, headers, libraries, etc. So, it’s usually simple to download a package with all files in, unzip to a directory and point the build system to that compiler, that will know about its location and find all it needs to when compiling your code.
  • Using these two, we can compile a program in a Mac that will run on that Linux like this: crystal build yourprogram.cr -cross-compile -target 'x8664-unknown-linux-gnu' This will generate a.o ( Object file ) and will print a line with a command to execute on the system we are trying to cross-compile to.

DO NOT USE THIS GUIDE, IT IS OUT OF DATE

The official version is compiled with osxcross: https://github.com/tpoechtrager/osxcross

Cross compiling for mac usually an almost impossible goal. The few cross compilers that exist don't work very well, and also require an actual SDK. This guide has you install a very easy to use cross compiler, which has been tested on Debian and Ubuntu based distros.

Start off by installing the libssl0.9.8 package. This is the only package required for the cross compiler to work. NOTE: You may not need to install this, if it came with your particular distro.

Clang/LLVM is a cross compiler by default and is now available on nearly every Linux distribution, so we just need a proper port of the cctools/ld64 and the macOS SDK. OSXCross includes a collection of scripts for preparing the SDK and building the cctools/ld64. Cross Compile on Mac OSX for mruby. Cross compile osx, linux or win32 binary of mruby on Mac OSX. Donwload and install by mrbgems Donwload mrbgem.

Next you need to get the actual cross compiler. It is provided in 5 .deb files which you need to install in order. The links to them are here: https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+packages . If you are on ubuntu you can try adding the ppa properly, except it probably will not work.

Install the packages in this order:

  • ccache-lipo
  • apple-x86-odcctools
  • apple-uni-sdk-10.5
  • apple-x86-gcc
  • apple-uni-framework-sdl

The rest of the packages you don't need. We install the 10.5 SDK because the 10.6 SDK doesn't seem to work.

All of the previous steps can be done easily with two scripts that are included. Just type these commands:

Replace 64 with 32 if you are using a 32 bit OS.


At this point you have a full cross compiler working and can actually compile using the --nolua and --nofft options. But compiling these libraries is very easy to do. Download this file: maccrosscompile.zip

Cross Compile Linux Kernel Module

Inside is a script cross-libs.sh. Type ./cross-libs.sh make lua fftw and then sudo ./cross-libs.sh install lua fftw. The script is already set up to download the libraries, cross compile them, and install them in the correct places.

Now it is time to compile. Go into the place where you keep your source code and type scons --mac. You can use the same folder where you compile the linux and windows versions, by adding --builddir=build/mac to make it compile in a separate directory. Ignore the compiler warnings that appear in SDLMain.m

Your compiled version will run on any 64 bit mac using OS X 10.5 or greater. It even supports fullscreen properly if you edit src/gui/options/OptionsView.cpp to enable it.

It is recommended to package the compiled binary into a .app file. The maccrosscompile.zip download above already has a completed .app for you. You just need to copy powder-x into Powder.app/Contents/MacOS. The Powder.app folder will be interpreted as a file by OS X. You will need to zip it up or use some other method to distribute it since you can't upload a folder.


If you have any problems following this guide, pm @jacob1 or find jacob1 in #powder on irc.freenode.net. Credit to jacksonmj for the cross-libs script, it was only modified to compile for mac instead of windows.

Retrieved from 'https://powdertoy.co.uk/Wiki/index.php?title=Compiling_for_Mac_on_Linux&oldid=7385'

Crystal supports a basic form of cross compilation.

In order to achieve this, the compiler executable provides two flags:

Cross Compile For Linux On Mac Os

  • --cross-compile: When given enables cross compilation mode
  • --target: the LLVM Target Triple to use and set the default compile-time flags from

To get the --target flags you can execute llvm-config --host-target using an installed LLVM 3.5. For example on a Linux it could say 'x86_64-unknown-linux-gnu'.

If you need to set any compile-time flags not set implicitly through --target, you can use the -D command line flag.

Using these two, we can compile a program in a Mac that will run on that Linux like this:

This will generate a .o (Object file) and will print a line with a command to execute on the system we are trying to cross-compile to. For example:

You must copy this .o file to that system and execute those commands. Once you do this the executable will be available in that target system.

This procedure is usually done with the compiler itself to port it to new platforms where a compiler is not yet available. Because in order to compile a Crystal compiler we need an older Crystal compiler, the only two ways to generate a compiler for a system where there isn't a compiler yet are:

  • We checkout the latest version of the compiler written in Ruby, and from that compiler we compile the next versions until the current one.
  • We create a .o file in the target system and from that file we create a compiler.
Linux

Clang Cross Compile For Linux On Mac

The first alternative is long and cumbersome, while the second one is much easier.

Cross Compile For Linux On Mac Download

Cross-compiling can be done for other executables, but its main target is the compiler. If Crystal isn't available in some system you can try cross-compiling it there.