Saturday, December 28, 2013

Compiling obj-c 2.0 with Foundation Kit on xubuntu 12.04 LTS with clang & llvm

This was tricky for me, so I am posting a guide as usual.

1. sudo apt-get install subversion
2. sudo apt-get install build-essential
3. sudo apt-get install pacman
4. sudo apt-get install libobjc2
5. sudo apt-get install clang

6. Then follow the instructions here:

Here is a sample program:

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])

    @autoreleasepool {
        // insert code here...
        NSLog(@"Hello, World!");
    return 0;


Save it as main.m and to compile it do:

sudo clang main.m `gnustep-config --objc-flags` `gnustep-config --objc-libs` -x objective-c -fconstant-string-class=NSConstantString -fobjc-nonfragile-abi -fblocks -lgnustep-base -lgnustep-gui -ldispatch -I /usr/include/GNUstep -L /usr/lib/GNUstep

it will create a file called a.out, to run it do:

sudo ./a.out


No comments:

Post a Comment