2011年1月4日 星期二

[記事] Objective-C in Linux (CentOS 5.4)

因為Mac不是人人玩得起的高貴玩意兒,為了那樣那樣,所以就有了這樣的一篇文章。金麻煩. In short

    # wget ftp://sourceware.org/pub/libffi/libffi-3.0.9.tar.gz
    # wget ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-base-1.20.1.tar.gz
    # wget ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-make-2.4.0.tar.gz

    # tar zxvf libffi-3.0.9.tar.gz
    # tar zxvf gnustep-base-1.20.1.tar.gz
    # tar zxvf gnustep-make-2.4.0.tar.gz

    # cd libffi-3.0.9
    # ./configure
    # make; make install
   
    # cd ../gnustep-make-2.4.0
    # ./configure ; make ; make install

    # . /usr/GNUstep/System/Library/Makefiles/GNUstep.csh
    # cd ../gnustep-base-1.20.1
    # ./configure --with-ffi-include=/usr/local/lib/libffi-3.0.9/include --with-ffi-library=/usr/local/lib/
    # make ; make install


    # vi hello.m
#import <Foundation/Foundation.h> 
int main (int argc, const char *argv[]) {
        //printf("hello world\n");
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        NSLog(@"hello world");
        [pool drain];
        return 0;
}

    #  gcc -I/usr/GNUstep/Local/Library/Headers -L /usr/GNUstep/Local/Library/Libraries -lgnustep-base -fconstant-string-class=NSConstantString hello.m -o hello

    #./hello
    2011-01-04 21:03:56.345 hello[17864] hello world

    Note : 不加  -fconstant-string-class=NSConstantString 會出現 cannot find interface declaration for ‘NXConstantString’ 的錯誤訊息,不加 -lgnustep-base ....嗯....自己看著辦

0 意見:

張貼留言