Hi everyone!
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. Eclipse C Compiler. With Eclipse you get advance functionality for programming in C, C on an. 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.
In our company we need to compile .app from Linux to Macos. And for now I just searched the internet about actual topics, and found only ones from 5 or more year older. Does anybody know any fresh solution for this?
Documentation tells me, that while building Qt from source, I have to specify flat -xplatform and tell it for example 'macx-clang'. But it always says me an error during build that 'Failed to process makespec for platform 'macx-clang'. Project ERROR: Could not resolve SDK Path for 'macosx'.'
I already get from the other projects some macos tools, such as otool, af, and others, and set some parameters in the configuration files for ./configure script. But this error comes from this variable 'QMAKE_MAC_SDK = macosx', and in the script further it goes to /usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK. And in Linux no such tool as xcodebuild, does it means that I can't build Qt from Lunux for Macos?
I also notices, that some old projects tells you to migrate xcode tools from mac to linux, and pack them in specific way, which i failed also, but anyways It doesn't tells you to specify this QMAKE_MAC_SDK.
Do you have any suggestions, how to fix any of my troubles or do it from scratch?
- 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
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
Install Mac Os On Linux
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.
![Cross Compile For Mac Os On Linux Cross Compile For Mac Os On Linux](/uploads/1/2/6/5/126558037/582562503.jpg)
add a section like this:
Cross Compile For Mac Os On Linux Mint
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.
Cross Compile For Osx On Linux
I may have missed some things (or most everything) as it's been a while since I did this.
Cross Compile For Mac Os On Linux Command
Retrieved from 'https://wiki.lazarus.freepascal.org/index.php?title=Cross_compiling_OSX_on_Linux&oldid=129917'