linux上安装GNUStep

1、安装GCC

(1)我安装的是gcc4.3.1,首先安装gmp-4.2.2 mpfr-2.3.1 mpfr带一个patch,这些东东是干什么用的我也不清楚;

(2)因为我的gmpmpfr都是安装在/usr/include下,所以configure时不需要指定--with-mpfr=mpfr目录 --with-gmp=gmp目录。运行configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-c99 --enable-long-long --enable-clocale=gnu --disable-libstdcxx-pch --disable-multilib。使用这个配置成功make之前的一些方案都没有成功,在这里没有指定--enable-languages表明支持所有的语言。

(3)使用gcc main.m可以编译下面的程序了

#import <stdio.h>

int main(int argc, char**argv)
{        
        printf("headfile dir is ok\n");
        return 0;
}

(4)刚高兴一下,编译下面的程序发现很多错误,上网一查,发现原来要使用:

Gcc main.m –l objc

实在是不容易啊。。。

错误:

tmp/ccW8mREn.o: In function `main':

test.m:(.text+0x5e): undefined reference to `objc_get_class'

test.m:(.text+0x71): undefined reference to `objc_msg_lookup'

test.m:(.text+0x98): undefined reference to `objc_msg_lookup'

test.m:(.text+0xc4): undefined reference to `objc_msg_lookup'

test.m:(.text+0xf0): undefined reference to `objc_msg_lookup'

test.m:(.text+0x114): undefined reference to `objc_msg_lookup'

/tmp/ccW8mREn.o: In function `__objc_gnu_init':

test.m:(.text+0x145): undefined reference to `__objc_exec_class'

/tmp/ccW8mREn.o:(.data+0x1a8): undefined reference to `__objc_class_name_Object'

collect2: ld returned 1 exit status

 

源代码:

#import <stdio.h>

#import <objc/Object.h>

// ----- @interface section ------

@interface Fraction:Object 

{

int numerator;

int denominator;

}

-(void) Print;

-(void) SetNumerator:(int) n;

-(void) SetDenominator:(int) d;

@end

// @implementation section

@implementation Fraction;

-(void)Print

{

printf("Fraction:%i/%i\n", numerator, denominator);

}

-(void) SetNumerator:(int) n

{

numerator = n;

}

-(void) SetDenominator:(int) d

{

denominator = d;

}

 

@end

 

 

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

{

Fraction* myFraction;

myFraction = [Fraction new];

 

[myFraction SetNumerator:1];

[myFraction SetDenominator:3];

 

[myFraction Print];

[myFraction free];

 

return 0;

}

 

2、安装GNU-Step

这里要推荐一个好网站http://wiki.gnustep.org/index.php/Main_Page

(1)    安装ffcall-1.10

(2)    安装tiff_3.8.2

(3)    安装gnustep-make-2.0.6并且在.bashrc中加入

GNUSTEP_ROOT=/usr/GNUstep

export GNUSTEP_ROOT

source /usr/GNUstep/System/Library/Makefiles/GNUstep.sh

(4)    重新运行终端,再安装gnustep-base-

posted @ 2009-11-09 22:01  六不朽  阅读(1429)  评论(0编辑  收藏  举报