File: node4.html

package info (click to toggle)
gnustep-tutorial 1.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 772 kB
  • ctags: 194
  • sloc: makefile: 46; perl: 6
file content (101 lines) | stat: -rw-r--r-- 3,121 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 99.2beta8 (1.43)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>A first App</TITLE>
<META NAME="description" CONTENT="A first App">
<META NAME="keywords" CONTENT="WritingMakefiles">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v99.2beta8">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="WritingMakefiles.css">

<LINK REL="next" HREF="node5.html">
<LINK REL="previous" HREF="node3.html">
<LINK REL="up" HREF="WritingMakefiles.html">
<LINK REL="next" HREF="node5.html">
</HEAD>

<BODY >
<B> Next:</B> <A NAME="tex2html54"
  HREF="node5.html">Debugging an Application</A>
<B>Up:</B> <A NAME="tex2html52"
  HREF="WritingMakefiles.html">Writing GNUstep Makefiles</A>
<B> Previous:</B> <A NAME="tex2html46"
  HREF="node3.html">Enabling Debugging</A>
<BR> <P>

<!--End of Navigation Panel-->

<H1><A NAME="SECTION00040000000000000000">
A first App</A>
</H1>
Let's try now to compile an application. 
Modify our source file <TT>source.m</TT> to read 
<PRE>
#import &lt;Foundation/Foundation.h&gt;
#import &lt;AppKit/AppKit.h&gt;

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

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

APP_NAME = PanelTest
PanelTest_OBJC_FILES = source.m

include $(GNUSTEP_MAKEFILES)/application.make
</PRE>
And that's it.  To compile, type in <TT>make</TT>.  
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 <TT>app</TT> appended.  In this case, after compilation 
the directory <TT>PanelTest.app</TT> should have been created. 
Our executable file is inside this directory; but the correct 
way to run the executable is through the <TT>openapp</TT> tool, 
in the following way: 
<PRE>
openapp PanelTest.app
</PRE>
(openapp should be in your path; if it is not, you should check that 
GNUstep is properly installed on your system). 

<P>
<BR><HR>
<ADDRESS>
Nicola Pero
2000-10-12
</ADDRESS>
</BODY>
</HTML>