From Inkscape Wiki
Revision as of 20:49, 5 June 2014 by LiamW (talk | contribs) (build dyld)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is being worked on, please maintain your patience. I have successfully done this before but I don't remember what I did, so I will have to recreate a lot of stuff.

You need:

  • a mind so deadset on cross-compiling you won't stop to think
  • the Xcode .dmg for your target OS X version
  • root access to your build system
  • a good processor and a lot of RAM

The following should be done on the host system first. Download the Xcode DMG, and use dmg2img to convert it to an IMG. Mount the IMG, and put the .pkg files into the chroot somewhere. I'm using /mnt/apple.

Making the chroot

I used Ubuntu 14.04 "Trusty Tahr" for doing the initial chroot. The process was as follows:

apt-get install dchroot debootstrap

Then edit /etc/schroot/schroot.conf with your favourite text editor, and add this at the end:

description=Ubuntu Trusty

Install a base system:

sudo debootstrap --variant=buildd --arch amd64 trusty /var/chroot/

where can be any of these mirrors.

Now copy your resolv.conf for internet access (required):

sudo cp /etc/resolv.conf /var/chroot/etc/resolv.conf

Bind your procfs into the chroot for gnustep:

sudo mount -o bind /proc /var/chroot/proc

Finally, chroot into your target:

sudo chroot /var/chroot

You should now have a working chroot, free for you to destroy as you see fit. (from

To avoid pointless warnings about missing locales, do this:

apt-get install language-pack-en

Install some packages to start off with:

apt-get install sudo nano vim bzr subversion groff man-db

Edit your /etc/apt/sources.list to include the universe source and update:

deb trusty main
deb-src trusty main

deb trusty universe
deb-src trusty universe

Now install gnustep:

apt-get install gnustep gnustep-devel

This may take a while.

Building clang

NOTE: There is a bug with building cross-compilers for OS X.

cd /usr/src
svn co llvm
cd llvm/tools
svn co clang
cd ..; mkdir build; cd build
../configure --prefix=/usr/clang_3_4 --enable-optimized --enable-targets=x86_64,x86 \
   --disable-compiler-version-checks --host=x86_64-unknown-linux-gnu --build=x86_64-unknown-linux-gnu \
make -j4
make install

Getting Headers

To tease the headers out of the Xcode so that we can compile anything, we need to install the xar archiver, which is not packaged in Trusty.

tar -xvf xar-1.5.2.tar.gz
apt-get install libxml2-dev libssl-dev libbz2-dev
cd xar-1.5.2; ./configure
make; make install

Now go to the location of your PKG files. Each one needs to be extracted, and then the payload needs to be extracted too.

cd /mnt/apple
mkdir DeveloperToolsCLI
cd DeveloperToolsCLI
xar -xvf ../DeveloperToolsCLI.pkg

Extract the payload (gzip doesn't really like unnamed files)

mv ./Payload ./Payload.gz
gunzip ./Payload.gz

The resulting file is a compressed CPIO archive. Extract that too:

mkdir Contents; cd Contents
cpio -idv < ../Payload

Okay, finally. Now we can figure out what's going where.

./System and ./Library are fine. We can just copy those over:

cp -R ./System /System
cp -R ./Library /Library

But ./usr is tricky — we might end up overwriting some sort of important file if we try just blatantly overwriting our /usr. So, what do we do? Scan the include paths for clang, and see what we can get away with, of course.

Next step: APSL headers for OSX, from Xcode, and then add libc++ compile instructions

Installing dyld

dyld is the Mach-O loader for OS X, and will allow you to run many command line tools for OS X. We need to install the GNUStep sources as well as the binaries here, be careful!

apt-get install git cmake clang nasm libxml2-dev libgnutls-dev libicu-dev libcairo-dev libjpeg-dev libpng-dev \
libtiff-dev libbsd-dev libudev-dev liblcms-dev libkqueue-dev libssl-dev libbz2-dev uuid-dev libncurses-dev \
libxrandr-dev libavcodec-dev libavformat-dev autoconf automake autopoint

Building gnustep-make

cd /usr/src
svn co gnustep-make
cd gnustep-make
CC=clang CXX=clang++ ./configure
make install

Building gnustep-libobjc2

svn co gnustep-libobjc2
cd gnustep-libobjc2
OBJCFLAGS=-fblocks CC=clang CXX=clang++ cmake .
rm GNUmakefile
make; make install

Building gnustep-base

svn co gnustep-base
cd gnustep-base
OBJCFLAGS=-fblocks CC=clang CXX=clang++ ./configure
make; make install

Building gnustep-gui

svn co gnustep-gui
cd gnustep-gui
OBJCFLAGS=-fblocks CC=clang CXX=clang++ ./configure
make; make install

Building libdispatch

git clone git:// libdispatch
cd libdispatch
make; make install

Building gnustep-corebase

svn co gnustep-corebase
cd gnustep-corebase

NOTE: there seems to be a bug in the configure script. To work around this bug, comment out these lines in

# AC_CHECK_LIB(dispatch, dispatch_get_main_queue_eventfd_np)
 # AS_IF([test "$ac_cv_lib_dispatch_dispatch_get_main_queue_eventfd_np" = "no"],
  # [AC_MSG_ERROR([Compatible libdispatch not found for GCD support! Use --disable-gcd to disable GCD support or install GCD.])])])

Then run:

autoconf > configure
OBJCFLAGS=-fblocks CC=clang CXX=clang++ ./configure
make; make install

Building darling


git clone
cd darling
CC=clang CXX=clang++ cmake .

There appears to be another bug here, in /usr/local/include/CoreFoundation/CFRunLoop.h:207. To fix it, just deactivate the code block like this:

DEFINE_BLOCK_TYPE_NO_ARGS(PerformBlockType, void);
CFRunLoopPerformBlock (CFRunLoopRef rl, CFTypeRef mode, PerformBlockType block);

Then continue:

make; make install

More coming...