Saturday, March 23, 2013


obj-c on debian7: success

Actually, I did try to use latest gcc version on debian 7 to compile command-line obj-c program, which I previously wrote on OS X and which makes use of certain Objective C 2 features.

This worked, with a few caveats:

  • You need to install gobjc++ and gnustep-devel packages (might be an overkill, but...)
  • If you plan to use GNUstep (that's the best way to guarantee compatibility with Apple tool chain), keep in mind that you'll need a special makefile (traditionally named GNUmakefile). Here is manual, and here is a basic example:

    include $(GNUSTEP_MAKEFILES)/common.make
    TOOL_NAME = rat
    rat_OBJC_FILES = Rational.m Expression.m main.m parser.m
    rat_HEADER_FILES = Rational.h Expression.h parse.h
    -include GNUmakefile.preamble
    include $(GNUSTEP_MAKEFILES)/tool.make
    -include GNUmakefile.postamble

  • For some reason, debian 7 version of GNUstep is missing definitions of TRUE and FALSE (though BOOL is defined?) and NS_REQUIRES_NIL_TERMINATION (see this recent patch). Therefore, I added this to one of the header files:

    #ifdef GNUSTEP
    #define FALSE 0
    #define TRUE 1
    #define NS_REQUIRES_NIL_TERMINATION __attribute__((sentinel))
    #endif /* GNUSTEP */
  • Also, these makefiles as described above require some environment variables; you can use

    source /usr/share/GNUstep/Makefiles/ 

    to set it up
  • There are some mysterious problems with version of ; you'll need to somehow convince your linked executable to load system version, e.g.:
    pushd ~/GNUstep/Library/Libraries
    ln -s /usr/lib/
  • Also, be mindful of 32/64-bit differences (since OS X is 64-bit only)

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?