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