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