150c3038832eb3a31727bef69f7f5f600e9253f9
[mono.git] / man / mcs.1
1 .TH mcs 1 "6 January 2001"
2 .SH NAME 
3 mcs \- Mono Compiler Suite.
4 .SH SYNOPSIS
5 .B mcs 
6 [option] [source-files]
7 .SH DESCRIPTION
8 mcs is the Mono C# compiler, an implementation of the ECMA-334
9 language specification.  You can pass one or more options to drive the
10 compiler, and a set of source files.  Extra options or arguments can
11 be provided in a response file.  Response files are referenced by
12 prepending the @ symbol to the response file name.
13 .PP
14 The Mono C# compiler accepts the same options than the Microsoft C#
15 compiler does.  Those options can start with a slash or a dash
16 (/checked is the same as -checked).  Additionally to this, the
17 GNU-like options are supported, those begin with "--".  All
18 MCS-specific flags which are not available in the Microsoft C#
19 compiler are available only with the GNU-style options. 
20 .PP
21 C# source files must end with a ".cs" extension.  Compilation of C#
22 source code requires all the files that make up a library, module or
23 executable to be provided on the command line.  There is no support
24 for partial compilation.  To achieve the benefits of partial
25 compilation, you should compile programs into their own assemblies,
26 and later reference them with the "-r" flag.
27 .PP
28 The Mono C# compiler generates images (.exe files) that contain CIL
29 byte code that can be executed by any system that implements a Common
30 Language Infrastructure virtual machine such as the Microsoft .NET
31 runtime engine on Windows or the Mono runtime engine on Unix systems.
32 Executables are not bound to a specific CPU or operating system.
33 .PP
34 .SH OPTIONS
35 .TP
36 .I \-\-about
37 Displays information about the Mono C# compiler
38 .TP
39 .I \-\-addmodule:MODULE1[,MODULE2]
40 Includes the specified modules in the resulting assembly.  
41 .TP
42 .I -checked, -checked+
43 Sets the default compilation mode to `checked'.  This makes all
44 the math operations checked (the default is unchecked).
45 .TP
46 .I -checked-
47 Sets the default compilation mode to `unchecked'.  This makes all
48 the math operations unchecked (this is the default).
49 .TP
50 .I -codepage:ID
51 Specifies the code page used to process the input files from the
52 point it is specified on.  By default files will be processed in the
53 Latin-1 code page.  The compiler will also automatically detect
54 Unicode files that have an embedded byte mark at the beginning.   The
55 special ID "utf8" can be used to switch to utf8 and the ID "reset"
56 restores the automatic handling of code pages.
57 .TP
58 Other popular encodings are 28591 (Latin1) and 1252 (iso-8859-1)
59 .TP
60 .I \-define:SYMLIST, -d:SYMLIST
61 Defines the symbol listed by the semi-colon separeted list SYMLIST
62 SYMBOL.  This can be tested in the source code by the pre-processor,
63 or can be used by methods that have been tagged with the Conditional
64 attribute. 
65 .TP
66 .I \-debug, \-debug+, \-g
67 Generate debugging information.  To obtain stack traces with debugging
68 information, you need to invoke the mono runtime with the `--debug'
69 flag.  This debugging information is stored inside the assembly as a
70 resource.
71 .TP
72 .I \-debug-
73 Do not generate debugging information.
74 .TP
75 .I \-delaysign+
76 Only embed the strongname public key into the assembly. The actual 
77 signing must be done in a later stage using the SN tool. This is useful
78 to protect the private key during development. Note that delay signing
79 can only be done using a strongname key file (not a key container). The
80 option is equivalent to including [assembly: AssemblyDelaySign (true)] 
81 in your source code. Compiler option takes precedence over the 
82 attributes.
83 .TP
84 .I \-delaysign-
85 Default. Strongname (sign) the assembly using the strong name key file
86 (or container). The option is equivalent to including [assembly: 
87 AssemblyDelaySign (false)] in your source code. Compiler option takes
88 precedence over the attributes.
89 .TP
90 .I \-doc:FILE
91 Extracts the C#/XML documentation from the source code and stores in in
92 the given FILE.
93 .TP
94 .I \-\-expect-error X L
95 The compiler will expect the code to generate an error 
96 named `X' in line `L'.  This is only used by the test suite.
97 .TP 
98 .I \-\-fatal 
99 This is used for debugging the compiler.  This makes the error emission
100 generate an exception that can be caught by a debugger.
101 .TP
102 .I \-keyfile:KEYFILE
103 Strongname (sign) the output assembly using the key pair present in 
104 the specified strong name key file (snk). A full key pair is required
105 by default (or when using delaysign-). A file containing only the
106 public key can be used with delaysign+. The option is equivalent to 
107 including [assembly: AssemblyKeyFile ("KEYFILE")] in your source code.
108 Compiler option takes precedence over the attributes.
109 .TP
110 .I \-keycontainer:CONTAINER
111 Strongname (sign) the output assembly using the key pair present in 
112 the specified container. Note that delaysign+ is ignored when using 
113 key containers. The option is equivalent to including [assembly: 
114 AssemblyKeyName ("CONTAINER")] in your source code. Compiler option 
115 takes precedence over the attributes.
116 .TP
117 .I \-langversion:TEXT
118 The option specifies the version of the language to use. The feature
119 set is different in each C# version. This switch can be used to force
120 the compiler to allow only a subset of the features.
121 The possible values are:
122 .nf
123
124 Default - Instruct compiler to use the latest version. Equivalent
125 is to omit the switch.
126
127 ISO-1   - Restrict compiler to use only ISO standardized features.
128 The usage of features such as generics, static classes, anonymous
129 methods will lead to error.
130 .TP
131 .I -lib:PATHLIST
132 Each path specified in the comma-separated list will direct the
133 compiler to look for libraries in that specified path.
134 .TP
135 .I \-L PATH
136 Directs the compiler to look for libraries in the specified path.
137 Multiple paths can be provided by using the option multiple times.
138 .TP
139 .I \-main:CLASS
140 Tells the compiler which CLASS contains the entry point. Useful when
141 you are compiling several classes with a Main method.
142 .TP
143 .I \-nostdlib, -nostdlib+
144 Use this flag if you want to compile the core library.  This makes the
145 compiler load its internal types from the assembly being compiled.
146 .TP
147 .I \-noconfig, \-noconfig+
148 Disables the default compiler configuration to be loaded.  The
149 compiler by default has references to the system assemblies. 
150 .TP
151 .I \-nowarn:WARNLIST
152 Makes the compiler ignore warnings specified in the comma-separeted
153 list WARNLIST>
154 .TP
155 .I -optimize, -optimize+, -optimize-
156 Controls whether to perform optimizations on the code.   -optimize and
157 -optimize+ will turn on optimizations, -optimize- will turn it off.
158 The default in mcs is to optimize+.
159 .TP
160 .I -out:FNAME, -o FNAME
161 Names the output file to be generated.
162 .TP
163 .I \-\-parse
164 Used for benchmarking.  The compiler will only parse its input files.
165 .TP
166 .I \-pkg:package1[,packageN]
167 The compiler will invoke pkg-config --libs on the set of packages
168 specified on the command line to obtain libraries and directories to
169 compile the code.
170 .PP
171 This is typically used with third party components, like this:
172 .nf
173                 $ mcs -pkg:gtk-sharp demo.cs
174 .fi
175 .TP
176 .TP
177 .I \-pkg:dotnet
178 This will instruct the compiler to reference the System.* libraries
179 available on a typical dotnet framework installation, notice that this
180 does not include all of the Mono libraies, only the System.* ones.  This
181 is a convenient shortcut for those porting code.
182 .TP
183 .I -resource:RESOURCE[,ID]
184 Embeds to the given resource file.  The optional ID can be used to
185 give a different name to the resource.  If not specified, the resource
186 name will be the file name.
187 .TP
188 .I -linkresource:RESOURCE[,ID]
189 Links to the specified RESOURCE.  The optional ID can be used to give
190 a name to the linked resource.
191 .TP
192 .I -r:ASSEMBLY1[,ASSEMBLY2], \-r ASSEMBLY1[,ASSEMBLY2]
193 Reference the named assemblies.  Use this to use classes from the named
194 assembly in your program.  The assembly will be loaded from either the
195 system directory where all the assemblies live, or from the path
196 explicitly given with the -L option.
197 .PP
198 You can also use a semicolon to separate the assemblies instead of a
199 comma. 
200 .TP
201 .I \-recurse:PATTERN, --recurse PATTERN
202 Does recursive compilation using the specified pattern.  In Unix the
203 shell will perform globbing, so you migth want to use it like this:
204 .PP
205 .nf
206                 $ mcs -recurse:'*.cs' 
207 .fi
208 .TP
209 .I \-\-stacktrace
210 Generates a stack trace at the time the error is reported, useful for
211 debugging the compiler.
212 .TP
213 .I \-target:KIND, \-t:KIND
214 Used to specify the desired target.  The possible values are: exe
215 (plain executable), winexe (Windows.Forms executable), library
216 (component libraries) and module (partial library).
217 .TP
218 .I \-\-timestamp
219 Another debugging flag.  Used to display the times at various points
220 in the compilation process.
221 .TP
222 .I \-unsafe, -unsafe+
223 Enables compilation of unsafe code.
224 .TP
225 .I \-v 
226 Debugging. Turns on verbose yacc parsing.
227 .TP
228 .I \-v2
229 Turns on C# 2.0 language features.
230 .TP
231 .I \-\-version
232 Shows the compiler version.
233 .TP
234 .I \-warnaserror, \-warnaserror+
235 Treat warnings as errors.
236 .TP
237 .I \-warn:LEVEL
238 Sets the warning level.  0 is the lowest warning level, and 4 is the
239 highest.  The default is 2.
240 .TP
241 .I \-win32res:FILE
242 Specifies a Win32 resource file (.res) to be bundled into the
243 resulting assembly.
244 .TP
245 .I \-win32icon:FILE
246 Attaches the icon specified in FILE on the output into the resulting
247 assembly.
248 .TP
249 .I \-\-
250 Use this to stop option parsing, and allow option-looking parameters
251 to be passed on the command line.
252 .PP
253 .SH SPECIAL DEFINES
254 The 
255 .B TRACE
256 and
257 .B DEBUG
258 defines have a special meaning to the compiler.
259 .PP
260 By default calls to methods and properties in the
261 System.Diagnostics.Trace class are not generated unless the TRACE
262 symbol is defined (either through a "#define TRACE") in your source
263 code, or by using the
264 .I "--define TRACE"
265 in the command line.
266 .PP
267 By default calls to methods and properties in the
268 System.Diagnostics.Debug class are not generated unless the DEBUG
269 symbol is defined (either through a "#define DEBUG") in your source
270 code, or by using the
271 .I "--define DEBUG"
272 in the command line.
273 .PP
274 Note that the effect of defining TRACE and DEBUG is a global setting,
275 even if they are only defined in a single file.
276 .PP
277 .SH DEBUGGING SUPPORT
278 When use the "--debug" or "-g" flag, MCS will create an assembler file
279 FILE-debug.s containing debugging information where FILE is the name of
280 the generated assembly. You need to run this file through the assembler
281 to get a object file FILE-debug.o.  See mono's "--dwarf-plus" argument
282 for details on how to use this file.
283 .SH NOTES
284 During compilation the MCS compiler defines the __MonoCS__ symbol,
285 this can be used by pre-processor instructions to compile Mono C#
286 compiler specific code.   Please note that this symbol is only to test
287 for the compiler, and is not useful to distinguish compilation or
288 deployment platforms.
289 .SH AUTHORS
290 The Mono C# Compiler was written by Miguel de Icaza, Ravi Pratap and
291 Martin Baulig at Ximian.
292 .PP
293 .SH LICENSE
294 The Mono Compiler Suite is released under the terms of the GNU GPL.
295 Please read the accompanying `COPYING' file for details.  Alternative
296 licenses are available from Ximian.
297 .PP
298 .SH SEE ALSO
299 mono(1), mint(1), sn(1)
300 .PP
301 .SH BUGS
302 To report bugs in the compiler, you can use `bug-buddy', or you can
303 file bug reports in our bug tracking system:
304 http://bugzilla.ximian.com.
305 .SH MAILING LIST
306 The Mono Mailing List is available at: mono-list-request@ximian.com
307 .SH MORE INFORMATION
308 The Mono C# compiler is developed by Ximian, Inc
309 (http://www.ximian.com) (http://www.ximian.com) and is based on the
310 ECMA C# language standard available here:
311 http://www.ecma.ch/ecma1/STAND/ecma-334.htm
312
313