1. 在软件中心安装 gnustep:
2. 在控制台输入:
#echo 'export LIBRARY_PATH=/usr/lib/GNUstep/System/Library/Libraries' >> ~/.profile |
2 | #echo 'export OBJC_INCLUDE_PATH=/usr/include/GNUstep/Headers' >> ~/.profile |
3 | #source ~/.profile |
然后执行GNUstep.sh的脚本,自动加载其他环境PATH:
1 | #chmod +x /usr/share/GNUstep/Makefiles/GNUstep.sh |
2 | #source /usr/share/GNUstep/Makefiles/GNUstep.sh |
也加入.profile文件, 以便用户登陆系统时加载
1 | #echo 'source /usr/share/GNUstep/Makefiles/GNUstep.sh' >> ~/.profile |
3. 安装gobjc
sudo apt-get install gobjc
4. 测试程序
#import <stdio.h> int main( int argc, const char *argv[] ) { printf( "hello world\n" ); return 0; }
然后执行编译:
gcc hello.m -o hello
如果调用到了 object-c的库, 以上编译命令会出错, 需要用下面命令:
gcc `gnustep-config --objc-flags` -lgnustep-base hello.m -o hello
然后允许代码看看
./hello
输入了
hello world
OK了