GNUStep:A first App

Let's try now to compile an application. Modify our source file  source.m  to read
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

int 
main (void)
{
  NSAutoreleasePool *pool;
  
  pool = [NSAutoreleasePool new];
  
  [NSApplication sharedApplication];
  
  NSRunAlertPanel (@"Test", @"Hello from the GNUstep AppKit", 
                   nil, nil, nil);

  return 0;
}
(Ignore the autorelease pool code for now - we'll cover autorelease pools in detail later). The line containing  sharedApplication  initializes the GNUstep GUI library; then, the following line runs an alert panel. To compile it, we rewrite the GNUmakefile as follows:
include $(GNUSTEP_MAKEFILES)/common.make

APP_NAME = PanelTest
PanelTest_OBJC_FILES = source.m

include $(GNUSTEP_MAKEFILES)/application.make
And that's it. To compile, type in  make . The result is slightly different from a command line tool. When building an application, the application usually has a set of resources (images, text files, sound files, bundles, etc) which comes with the application. In the GNUstep framework, these resources are stored with the application executable in an 'application directory', named after the application, with  app  appended. In this case, after compilation the directory  PanelTest.app  should have been created. Our executable file is inside this directory; but the correct way to run the executable is through the  openapp  tool, in the following way:
openapp ./PanelTest.app

(openapp should be in your path; if it is not, you should check that GNUstep is properly installed on your system).


Debugging an application is quite simple. Applications, like tools and everything else, are compiled with debugging enabled by default; to debug the application, use

openapp --debug ./PanelTest.app
This will run  gdb  (the GNU debugger) on the executable setting everything ready for debugging.


转载:http://www.gnustep.it/nicola/Tutorials/WritingMakefiles/node6.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值