Begin main content

GNUstep bleeding edge

For a client project I'm looking into Mac/Linux GUI cross platform options. Naturally GNUstep is high on my list. It's been a while (maybe 10 years) since I even played with GNUstep and I've struggled a bit getting all the latest things to compile together. So, like everyone else, I'm putting together a guide for how I did it since none of the other guides seem to be up to date (and I'm sure mine will be out of date shortly too!)

I'm installing on Ubuntu 12.04, but other Linux platforms will be very similar - just the dependencies might be different.

So firstly about those package dependencies. I've done so many apt-get installs that I've lost track exactly what I needed. Something a bit like this:

sudo aptitude install build-essential git subversion ninja cmake libffi-dev libxml2-dev libgnutls-dev libicu-dev libblocksruntime-dev libkqueue-dev libpthread-workqueue-dev autoconf libtool

Make sure you've uninstalled any older clang or libobjc libraries (otherwise you'll need to be very careful with configure args etc. to specify our compiled versions) and also any older version of libdispatch

Firstly we want the trunk version of llvm/clang. Grit your teeth, because we're going to have to use subversion:

cd
mkdir -p src/gnustep
cd src/gnustep
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ..
mkdir build
cd build
cmake ..
make -j4

Now add the following to your .bashrc etc:

export PATH=$PATH:~/src/gnustep/llvm/build/bin
export CC=clang
export CXX=clang++

Now reload your bashrc:

. ~/.bashrc

Check you can find clang:

which clang
clang -v
clang++ 0v

Now we want the latest gnustep libobjc2 with all the latest modern runtime goodies:

cd ~/src/gnustep
git clone https://github.com/gnustep/gnustep-libobjc2.git
cd gnustep-libobjc2
mkdir build
cd build
cmake ..
make -j4
sudo -E make install

Now add the following to your .bashrc:

export OBJCFLAGS="-fblocks -fobjc-runtime=gnustep"

cd ~/src/gnustep
git clone https://github.com/gnustep/gnustep-make.git
cd gnustep-make
./configure --enable-debug-by-default --with-layout=gnustep --enable-objc-nonfragile-abi
make
sudo -E make install

Now add the following to your .bashrc:

. /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
. ~/.bashrc

Now we can start installing gnustep itself:

cd ~/src/gnustep
git clone https://github.com/gnustep/gnustep-base.git
cd gnustep-base
./configure
make -j4
sudo -E make install

If you get warnings about blocks during make, check that you don't have old libobjc libraries on your system. You can specify a particular libobjc library version when you build the gnustep-make package, but easier to just uninstall them.

Now lets run some tests.

make check

The gnustep-base check tests are very handy for making sure you have all the latest things. Warnings you should look out for are things like you haven't enabled blocks or subscripting. If you get warnings like that you should check your OBJCFLAGS etc. At this point I get no failures or skips:

7913 Passed tests 21 Dashed hopes

All OK!

Now we want the latest lib dispatch for all our GCD goodness:

cd ~/src/gnustep git clone git://github.com/nickhutchinson/libdispatch.git
cd libdispatch
sh autogen.sh
./configure CFLAGS="-I/usr/include/kqueue" LDFLAGS="-lkqueue -lpthread_workqueue -pthread -lm"
make clean make -j4
sudo -E make install sudo ldconfig

Now we can compile some test code from this post (http://lists.gnu.org/archive/html/discuss-gnustep/2012-12/msg00036.html) which I have pasted into a gist: https://gist.github.com/aufflick/5674798

clang `gnustep-config --objc-flags` `gnustep-config --objc-libs` -lobjc blocktest.m
./a.out

clang `gnustep-config --objc-flags` `gnustep-config --objc-libs` -lobjc -ldispatch -lgnustep-base Fraction.m helloGCD_objc.m
./a.out

And there we are! Ready to install the other gnustep-* modules from github.

08:10 PM, 29 May 2013 by Mark Aufflick Permalink

Add comment