1 .de Sp \" Vertical space (when we can't use .PP)
5 .TH mcs 1 "6 January 2001"
7 mcs, gmcs, smcs \- Mono C# Compiler (1.0, 2.0, Moonlight)
10 [option] [source-files]
12 mcs is the Mono C# compiler, an implementation of the ECMA-334
13 language specification. You can pass one or more options to drive the
14 compiler, and a set of source files. Extra options or arguments can
15 be provided in a response file. Response files are referenced by
16 prepending the @ symbol to the response file name.
20 compiler is used to compile against the 1.x profile and implements
21 C# 1.0 and 2.0 with the exception of generics and nullable types.
25 compiler is used to compile against the 2.0 profile and implements
26 the complete C# 2.0 specification including generics.
30 compiler is used to compile against the Silverlight/Moonlight profile.
31 This profile is designed to be used for creating Silverlight/Moonlight
32 applications that will run on a web browser. The API exposed by this
33 profile is a small subset of the 3.5 API (even if it is commonly
34 referred as the 2.1 API, this API is a small subset of 2.0 with a few
35 extensions), in addition this profile by default runs with
36 -langversion:linq which turns on the C# 3.0 language by default.
38 See the section on packages for more information.
40 The Mono C# compiler accepts the same command line options that the
41 Microsoft C# compiler does. Those options can start with a slash or a
42 dash (/checked is the same as -checked). Additionally some GNU-like
43 options are supported, those begin with "--". All MCS-specific flags
44 which are not available in the Microsoft C# compiler are available
45 only with the GNU-style options.
47 C# source files must end with a ".cs" extension. Compilation of C#
48 source code requires all the files that make up a library, module or
49 executable to be provided on the command line. There is no support
50 for partial compilation. To achieve the benefits of partial
51 compilation, you should compile programs into their own assemblies,
52 and later reference them with the "-r" flag.
54 The Mono C# compiler generates images (.exe files) that contain CIL
55 byte code that can be executed by any system that implements a Common
56 Language Infrastructure virtual machine such as the Microsoft .NET
57 runtime engine on Windows or the Mono runtime engine on Unix systems.
58 Executables are not bound to a specific CPU or operating system.
60 The Mono C# compiler by default only references three assemblies:
61 mscorlib.dll, System.dll and System.Xml.dll. If you want to
62 reference extra libraries you must manually specify them using the
63 -pkg: command line option or the -r: command line option.
64 Alternatively if you want to get all of the System libraries, you can
65 use the -pkg:dotnet command line option.
70 Displays information about the Mono C# compiler
72 .I \-\-addmodule:MODULE1[,MODULE2]
73 Includes the specified modules in the resulting assembly. Modules are
74 created by calling the compiler with the -target:module option
76 .I -checked, -checked+
77 Sets the default compilation mode to `checked'. This makes all
78 the math operations checked (the default is unchecked).
81 Sets the default compilation mode to `unchecked'. This makes all
82 the math operations unchecked (this is the default).
84 .I -clscheck-, -clscheck+
85 Disables or enables the Common Language Specification (CLS) checks (it
86 is enabled by default).
88 The Common Language Specification (CLS) defines an interoperable
89 subset of types as well as conventions that compilers (CLS producers)
90 and developers must follow to expose code to other programming
91 languages (CLS consumers).
94 Specifies the code page used to process the input files from the
95 point it is specified on. By default files will be processed in the
96 environment-dependent native code page. The compiler will also automatically
97 detect Unicode files that have an embedded byte mark at the beginning.
99 Other popular encodings are 28591 (Latin1), 1252 (iso-8859-1) and 65001 (UTF-8).
101 MCS supports a couple of shorthands: "utf8" can be used to specify utf-8 instead
102 of using the cryptic 65001 and "reset" restores the automatic handling of
103 code pages. These shorthands are not available on the Microsoft compiler.
105 .I \-define:SYMLIST, -d:SYMLIST
106 Defines the symbol listed by the semi-colon separated list SYMLIST
107 SYMBOL. This can be tested in the source code by the pre-processor,
108 or can be used by methods that have been tagged with the Conditional
111 .I \-debug, \-debug+, \-g
112 Generate debugging information. To obtain stack traces with debugging
113 information, you need to invoke the mono runtime with the `--debug'
114 flag. This debugging information is stored inside the assembly as a
118 Do not generate debugging information.
121 Only embed the strongname public key into the assembly. The actual
122 signing must be done in a later stage using the SN tool. This is useful
123 to protect the private key during development. Note that delay signing
124 can only be done using a strongname key file (not a key container). The
125 option is equivalent to including [assembly: AssemblyDelaySign (true)]
126 in your source code. Compiler option takes precedence over the
130 Default. Strongname (sign) the assembly using the strong name key file
131 (or container). The option is equivalent to including [assembly:
132 AssemblyDelaySign (false)] in your source code. Compiler option takes
133 precedence over the attributes.
136 Extracts the C#/XML documentation from the source code and stores in in
139 .I \-\-expect-error X L
140 The compiler will expect the code to generate an error
141 named `X' in line `L'. This is only used by the test suite.
144 This is used for debugging the compiler. This makes the error emission
145 generate an exception that can be caught by a debugger.
148 Strongname (sign) the output assembly using the key pair present in
149 the specified strong name key file (snk). A full key pair is required
150 by default (or when using delaysign-). A file containing only the
151 public key can be used with delaysign+. The option is equivalent to
152 including [assembly: AssemblyKeyFile ("KEYFILE")] in your source code.
153 Compiler option takes precedence over the attributes.
155 .I \-keycontainer:CONTAINER
156 Strongname (sign) the output assembly using the key pair present in
157 the specified container. Note that delaysign+ is ignored when using
158 key containers. The option is equivalent to including [assembly:
159 AssemblyKeyName ("CONTAINER")] in your source code. Compiler option
160 takes precedence over the attributes.
162 .I \-langversion:TEXT
163 The option specifies the version of the language to use. The feature
164 set is different in each C# version. This switch can be used to force
165 the compiler to allow only a subset of the features.
166 The possible values are:
171 Instruct compiler to use the latest version. Equivalent is to omit the
172 switch (this currently defaults to the C# 2.0 language specification).
175 Restrict compiler to use only first ISO standardized features.
176 The usage of features such as generics, static classes, anonymous
177 methods will lead to error.
180 Restrict compiler to use only the second ISO standardized features.
181 This allows the use of generics, static classes, iterators and
182 anonymous methods for example.
185 This enables the C# 3.0 support. Only a few features of C# 3.0 have
186 been implemented in the Mono C# compiler, so not everything is
189 Notice that this flag only controls the language features available to
190 the programmer, it does not control the kind of assemblies produced.
191 Programs compiled with mcs will reference the 1.1 APIs, Programs
192 compiled with gmcs reference the 2.0 APIs.
197 Each path specified in the comma-separated list will direct the
198 compiler to look for libraries in that specified path.
201 Directs the compiler to look for libraries in the specified path.
202 Multiple paths can be provided by using the option multiple times.
205 Tells the compiler which CLASS contains the entry point. Useful when
206 you are compiling several classes with a Main method.
208 .I \-nostdlib, -nostdlib+
209 Use this flag if you want to compile the core library. This makes the
210 compiler load its internal types from the assembly being compiled.
212 .I \-noconfig, \-noconfig+
213 Disables the default compiler configuration to be loaded. The
214 compiler by default has references to the system assemblies.
217 Makes the compiler ignore warnings specified in the comma-separated
220 .I -optimize, -optimize+, -optimize-
221 Controls whether to perform optimizations on the code. -optimize and
222 -optimize+ will turn on optimizations, -optimize- will turn it off.
223 The default in mcs is to optimize+.
225 .I -out:FNAME, -o FNAME
226 Names the output file to be generated.
229 Used for benchmarking. The compiler will only parse its input files.
231 .I \-pkg:package1[,packageN]
232 Reference assemblies for the given packages.
234 The compiler will invoke pkg-config --libs on the set of packages
235 specified on the command line to obtain libraries and directories to
238 This is typically used with third party components, like this:
241 $ mcs -pkg:gtk-sharp demo.cs
247 This will instruct the compiler to reference the System.* libraries
248 available on a typical dotnet framework installation, notice that this
249 does not include all of the Mono libraries, only the System.* ones. This
250 is a convenient shortcut for those porting code.
253 Use this to reference the "Olive" libraries (the 3.0 and 3.5 extended
257 References the assemblies for creating Moonlight/Silverlight
258 applications. This is automatically used when using the
260 compiler, but it is here when developers want to use it with the
264 .I \-pkg:silverdesktop
265 Use this option to create Moonlight/Silverlight applications that
266 target the desktop. This option allows developers to consume the
267 Silverlight APIs with the full 2.0 profile API available to them,
270 it gives full access to all the APIs that are part of Mono. The only
271 downside is that applications created with silverdesktop will not run
272 on the browser. Typically these applications will be launched
277 For more details see the PACKAGE section in this document
281 .I -resource:RESOURCE[,ID]
282 Embeds to the given resource file. The optional ID can be used to
283 give a different name to the resource. If not specified, the resource
284 name will be the file name.
286 .I -linkresource:RESOURCE[,ID]
287 Links to the specified RESOURCE. The optional ID can be used to give
288 a name to the linked resource.
290 .I -r:ASSEMBLY1[,ASSEMBLY2], \-reference ASSEMBLY1[,ASSEMBLY2]
291 Reference the named assemblies. Use this to use classes from the named
292 assembly in your program. The assembly will be loaded from either the
293 system directory where all the assemblies live, or from the path
294 explicitly given with the -L option.
296 You can also use a semicolon to separate the assemblies instead of a
299 .I -reference:ALIAS=ASSEMBLY
300 Extern alias reference support for C#.
302 If you have different assemblies that provide the same types, the
303 extern alias support allows you to provide names that your software
304 can use to tell those appart. The types from ASSEMBLY will be
305 exposed as ALIAS, then on the C# source code, you need to do:
310 To bring it into your namespace. For example, to cope with two
311 graphics libraries that define "Graphics.Point", one in
312 "OpenGL.dll" and one in "Postscript.dll", you would invoke the
316 mcs -r:Postscript=Postscript.dll -r:OpenGL=OpenGL.dll
319 And in your source code, you would write:
322 extern alias Postscript;
326 // This is a Graphics.Point from Postscrip.dll
327 Postscript.Point p = new Postscript.Point ();
329 // This is a Graphics.Point from OpenGL.dll
330 OpenGL.Point p = new OpenGL.Point ();
334 .I \-recurse:PATTERN, --recurse PATTERN
335 Does recursive compilation using the specified pattern. In Unix the
336 shell will perform globbing, so you might want to use it like this:
339 $ mcs -recurse:'*.cs'
343 Generates a stack trace at the time the error is reported, useful for
344 debugging the compiler.
346 .I \-target:KIND, \-t:KIND
347 Used to specify the desired target. The possible values are: exe
348 (plain executable), winexe (Windows.Forms executable), library
349 (component libraries) and module (partial library).
352 Another debugging flag. Used to display the times at various points
353 in the compilation process.
355 .I \-unsafe, -unsafe+
356 Enables compilation of unsafe code.
359 Debugging. Turns on verbose yacc parsing.
362 Turns on C# 2.0 language features.
365 Shows the compiler version.
367 .I \-warnaserror, \-warnaserror+
368 Treat warnings as errors.
371 Sets the warning level. 0 is the lowest warning level, and 4 is the
372 highest. The default is 2.
375 Specifies a Win32 resource file (.res) to be bundled into the
379 Attaches the icon specified in FILE on the output into the resulting
383 Use this to stop option parsing, and allow option-looking parameters
384 to be passed on the command line.
387 Depending on the invocation for the C# compiler (mcs, gmcs, or smcs)
388 you will get a default set of libraries and versions of those
389 libraries that are referenced.
391 The compiler uses the library path to locate libraries, and is able to
392 reference libraries from a particular package if that directory is
393 used. To simplify the use of packages, the C# compiler includes the
394 -pkg: command line option that is used to load specific collections of
397 Libraries visible to the compiler are stored relative to the
398 installation prefix under PREFIX/lib/mono/ called the PACKAGEBASE and the
399 defaults for mcs, gmcs and smcs are as follows:
402 References the PACKAGEBASE/1.0 directory
405 References the PACKAGEBASE/2.0 directory
408 References the PACKAGEBASE/2.1 directory
410 Those are the only runtime profiles that exist. Although other
411 directories exist (like 3.0 and 3.5) those are not really runtime
412 profiles, they are merely placeholders for extra libraries that build
413 on the 2.0 foundation.
415 Software providers will distribute software that is installed relative
416 to the PACKAGEBASE directory. This is integrated into the
418 tool that not only installs public assemblies into the Global Assembly
419 Cache (GAC) but also installs them into the PACKAGEBASE/PKG directory
420 (where PKG is the name passed to the -package flag to gacutil).
422 As a developer, if you want to consume the Gtk# libraries, you would
423 invoke the compiler like this:
426 $ mcs -pkg:gtk-sharp-2.0 main.cs
429 The -pkg: option instructs the compiler to fetch the definitions for
430 gtk-sharp-2.0 from pkg-config, this is equivalent to passing to the C#
431 compiler the output of:
434 $ pkg-config --libs gtk-sharp-2.0
437 Usually this merely references the libraries from PACKAGEBASE/PKG.
439 Although there are directory names for 3.0 and 3.5, that does not mean
440 that there are 3.0 and 3.5 compiler editions or profiles. Those are
441 merely new libraries that must be manually referenced either with the
442 proper -pkg: invocation, or by referencing the libraries directly.
449 defines have a special meaning to the compiler.
451 By default calls to methods and properties in the
452 System.Diagnostics.Trace class are not generated unless the TRACE
453 symbol is defined (either through a "#define TRACE") in your source
454 code, or by using the
458 By default calls to methods and properties in the
459 System.Diagnostics.Debug class are not generated unless the DEBUG
460 symbol is defined (either through a "#define DEBUG") in your source
461 code, or by using the
465 Note that the effect of defining TRACE and DEBUG is a global setting,
466 even if they are only defined in a single file.
468 .SH DEBUGGING SUPPORT
469 When using the "-debug" flag, MCS will generate a file with the
470 extension .mdb that contains the debugging information for the
471 generated assembly. This file is consumed by the Mono debugger (mdb).
472 .SH ENVIRONMENT VARIABLES
475 If this variable is set, it contains a string in the form
476 "foreground,background" that specifies which color to use to display
477 errors on some terminals.
479 The background is optional and defaults to your terminal current
480 background. The possible colors for foreground are:
481 .B black, red, brightred, green, brightgreen, yellow, brightyellow,
482 blue, brightblue, magenta, brightmagenta, cyan, brightcyan, grey,
483 white and brightwhite.
485 The possible colors for background are: black, red, green, yellow,
486 blue, magenta, cyan, grey and white.
488 For example, you could set these variable from your shell:
491 MCS_COLORS=errors=brightwhite,red
494 You can disable the built-in color scheme by setting this variable to
497 During compilation the MCS compiler defines the __MonoCS__ symbol,
498 this can be used by pre-processor instructions to compile Mono C#
499 compiler specific code. Please note that this symbol is only to test
500 for the compiler, and is not useful to distinguish compilation or
501 deployment platforms.
503 The Mono C# Compiler was written by Miguel de Icaza, Ravi Pratap,
504 Martin Baulig, Marek Safar and Raja Harinath. The development was
505 funded by Ximian, Novell and Marek Safar.
508 The Mono Compiler Suite is released under the terms of the GNU GPL.
509 Please read the accompanying `COPYING' file for details. Alternative
510 licensing for the compiler is available from Novell.
513 mdb(1), mono(1), mopen(1), mint(1), sn(1)
516 To report bugs in the compiler, you must file them on our bug tracking
518 http://www.mono-project.com/Bugs
520 The Mono Mailing lists are listed at http://www.mono-project.com/Mailing_Lists
522 The Mono C# compiler was developed by Novell, Inc
523 (http://www.novell.com, http) and is based on the
524 ECMA C# language standard available here:
525 http://www.ecma.ch/ecma1/STAND/ecma-334.htm
527 The home page for the Mono C# compiler is at http://www.mono-project.com/CSharp_Compiler