1mcs(1)                      General Commands Manual                     mcs(1)
2
3
4

NAME

6       mcs, gmcs - Mono C# Compiler (1.0 and 2.0)
7

SYNOPSIS

9       mcs [option] [source-files]
10

DESCRIPTION

12       mcs is the Mono C# compiler, an implementation of the ECMA-334 language
13       specification.  You can pass one or more options to drive the compiler,
14       and  a set of source files.  Extra options or arguments can be provided
15       in a response file.  Response files are referenced by prepending the  @
16       symbol to the response file name.
17
18       The  mcs compiler is used to compile against the 1.x profile and imple‐
19       ments C# 1.0 and 2.0 with the exception of generics and nullable types.
20       The gmcs compiler is used to compile against the 2.x profile and imple‐
21       ments the complete C# 2.0 specification including generics.
22
23       The Mono C# compiler accepts the same command line options that the Mi‐
24       crosoft  C#  compiler  does.  Those options can start with a slash or a
25       dash (/checked is the same as -checked).   Additionally  some  GNU-like
26       options  are  supported, those begin with "--".  All MCS-specific flags
27       which are not available in the Microsoft C# compiler are available only
28       with the GNU-style options.
29
30       C#  source  files  must  end with a ".cs" extension.  Compilation of C#
31       source code requires all the files that make up a  library,  module  or
32       executable to be provided on the command line.  There is no support for
33       partial compilation.  To achieve the benefits of  partial  compilation,
34       you should compile programs into their own assemblies, and later refer‐
35       ence them with the "-r" flag.
36
37       The Mono C# compiler generates images (.exe  files)  that  contain  CIL
38       byte  code  that can be executed by any system that implements a Common
39       Language Infrastructure virtual machine such as the Microsoft .NET run‐
40       time  engine  on  Windows  or  the Mono runtime engine on Unix systems.
41       Executables are not bound to a specific CPU or operating system.
42
43       The Mono C# compiler  by  default  only  references  three  assemblies:
44       mscorlib.dll, System.dll and System.Xml.dll.   If you want to reference
45       extra libraries you must manually specify them using the -pkg:  command
46       line  option or the -r: command line option.  Alternatively if you want
47       to get all of the System libraries, you can use the -pkg:dotnet command
48       line option.
49

OPTIONS

51       --about
52              Displays information about the Mono C# compiler
53
54       --addmodule:MODULE1[,MODULE2]
55              Includes the specified modules in the resulting assembly.
56
57       -checked, -checked+
58              Sets  the default compilation mode to `checked'.  This makes all
59              the math operations checked (the default is unchecked).
60
61       -checked-
62              Sets the default compilation mode to  `unchecked'.   This  makes
63              all the math operations unchecked (this is the default).
64
65       -codepage:ID
66              Specifies the code page used to process the input files from the
67              point it is specified on.  By default files will be processed in
68              the  Latin-1  code  page.   The compiler will also automatically
69              detect Unicode files that have an  embedded  byte  mark  at  the
70              beginning.
71
72       Other popular encodings are 28591 (Latin1), 1252 (iso-8859-1) and 65001
73       (UTF-8).
74
75       MCS supports a couple of shorthands: "utf8"  can  be  used  to  specify
76       utf-8 instead
77              of  using  the  cryptic 65001 and "reset" restores the automatic
78              handling of code pages.  These shorthands are not  available  on
79              the Microsoft compiler.
80
81       -define:SYMLIST, -d:SYMLIST
82              Defines  the symbol listed by the semi-colon separated list SYM‐
83              LIST SYMBOL.  This can be tested in the source code by the  pre-
84              processor,  or can be used by methods that have been tagged with
85              the Conditional attribute.
86
87       -debug, -debug+, -g
88              Generate debugging information.  To  obtain  stack  traces  with
89              debugging  information, you need to invoke the mono runtime with
90              the `--debug' flag.  This debugging information is stored inside
91              the assembly as a resource.
92
93       -debug-
94              Do not generate debugging information.
95
96       -delaysign+
97              Only  embed  the  strongname  public  key into the assembly. The
98              actual signing must be done in a later stage using the SN  tool.
99              This  is  useful  to protect the private key during development.
100              Note that delay signing can only be done using a strongname  key
101              file  (not a key container). The option is equivalent to includ‐
102              ing [assembly: AssemblyDelaySign (true)] in  your  source  code.
103              Compiler option takes precedence over the attributes.
104
105       -delaysign-
106              Default.  Strongname  (sign)  the assembly using the strong name
107              key file (or container). The option is equivalent  to  including
108              [assembly:  AssemblyDelaySign (false)] in your source code. Com‐
109              piler option takes precedence over the attributes.
110
111       -doc:FILE
112              Extracts the C#/XML  documentation  from  the  source  code  and
113              stores in in the given FILE.
114
115       --expect-error X L
116              The compiler will expect the code to generate an error named `X'
117              in line `L'.  This is only used by the test suite.
118
119       --fatal
120              This is used for debugging the compiler.  This makes  the  error
121              emission generate an exception that can be caught by a debugger.
122
123       -keyfile:KEYFILE
124              Strongname (sign) the output assembly using the key pair present
125              in the specified strong name key file (snk). A full key pair  is
126              required  by default (or when using delaysign-). A file contain‐
127              ing only the public key can be used with delaysign+. The  option
128              is  equivalent  to  including  [assembly: AssemblyKeyFile ("KEY‐
129              FILE")] in your source code.  Compiler option  takes  precedence
130              over the attributes.
131
132       -keycontainer:CONTAINER
133              Strongname (sign) the output assembly using the key pair present
134              in the specified container. Note that delaysign+ is ignored when
135              using  key  containers.  The  option  is equivalent to including
136              [assembly: AssemblyKeyName ("CONTAINER")] in your  source  code.
137              Compiler option takes precedence over the attributes.
138
139       -langversion:TEXT
140              The  option  specifies  the  version of the language to use. The
141              feature set is different in each C# version. This switch can  be
142              used  to  force  the compiler to allow only a subset of the fea‐
143              tures.  The possible values are:
144
145              Default - Instruct compiler to use the latest version. Equivalent
146              is to omit the switch.
147
148              ISO-1   - Restrict compiler to use only ISO standardized features.
149              The usage of features such as generics, static classes, anonymous
150              methods will lead to error.
151              Notice that this flag only controls the language features available to
152              the programmer, it does not control the kind of assemblies produced.
153              Programs compiled with mcs will reference the 1.1 APIs, Programs
154              compiled with gmcs reference the 2.0 APIs.
155
156       -lib:PATHLIST
157              Each path specified in the comma-separated list will direct the
158              compiler to look for libraries in that specified path.
159
160       -L PATH
161              Directs the compiler to look for libraries in the specified path.
162              Multiple paths can be provided by using the option multiple times.
163
164       -main:CLASS
165              Tells the compiler which CLASS contains the entry point. Useful when
166              you are compiling several classes with a Main method.
167
168       -nostdlib, -nostdlib+
169              Use this flag if you want to compile the core library.  This makes the
170              compiler load its internal types from the assembly being compiled.
171
172       -noconfig, -noconfig+
173              Disables the default compiler configuration to be loaded.  The
174              compiler by default has references to the system assemblies.
175
176       -nowarn:WARNLIST
177              Makes the compiler ignore warnings specified in the comma-separated
178              list WARNLIST>
179
180       -optimize, -optimize+, -optimize-
181              Controls whether to perform optimizations on the code.   -optimize and
182              -optimize+ will turn on optimizations, -optimize- will turn it off.
183              The default in mcs is to optimize+.
184
185       -out:FNAME, -o FNAME
186              Names the output file to be generated.
187
188       --parse
189              Used for benchmarking.  The compiler will only parse its input files.
190
191       -pkg:package1[,packageN]
192              The compiler will invoke pkg-config --libs on the set of packages
193              specified on the command line to obtain libraries and directories to
194              compile the code.
195
196       This is typically used with third party components, like this:
197                 $ mcs -pkg:gtk-sharp demo.cs
198
199
200       -pkg:dotnet
201              This will instruct the compiler to reference the System.*
202              libraries available on a typical dotnet framework instal‐
203              lation, notice that this does not include all of the Mono
204              libraries,  only the System.* ones.  This is a convenient
205              shortcut for those porting code.
206
207       -resource:RESOURCE[,ID]
208              Embeds to the given resource file.  The optional  ID  can
209              be used to give a different name to the resource.  If not
210              specified, the resource name will be the file name.
211
212       -linkresource:RESOURCE[,ID]
213              Links to the specified RESOURCE.  The optional ID can  be
214              used to give a name to the linked resource.
215
216       -r:ASSEMBLY1[,ASSEMBLY2], -r ASSEMBLY1[,ASSEMBLY2]
217              Reference  the named assemblies.  Use this to use classes
218              from the named assembly in your  program.   The  assembly
219              will be loaded from either the system directory where all
220              the assemblies live, or from the  path  explicitly  given
221              with the -L option.
222
223       You  can also use a semicolon to separate the assemblies instead
224       of a comma.
225
226       -recurse:PATTERN, --recurse PATTERN
227              Does recursive compilation using the  specified  pattern.
228              In  Unix  the  shell  will perform globbing, so you might
229              want to use it like this:
230
231                 $ mcs -recurse:'*.cs'
232
233       --stacktrace
234              Generates  a  stack  trace  at  the  time  the  error  is
235              reported, useful for debugging the compiler.
236
237       -target:KIND, -t:KIND
238              Used  to specify the desired target.  The possible values
239              are: exe (plain executable), winexe  (Windows.Forms  exe‐
240              cutable),  library (component libraries) and module (par‐
241              tial library).
242
243       --timestamp
244              Another debugging flag.  Used to  display  the  times  at
245              various points in the compilation process.
246
247       -unsafe, -unsafe+
248              Enables compilation of unsafe code.
249
250       -v     Debugging. Turns on verbose yacc parsing.
251
252       -v2    Turns on C# 2.0 language features.
253
254       --version
255              Shows the compiler version.
256
257       -warnaserror, -warnaserror+
258              Treat warnings as errors.
259
260       -warn:LEVEL
261              Sets  the  warning level.  0 is the lowest warning level,
262              and 4 is the highest.  The default is 2.
263
264       -win32res:FILE
265              Specifies a Win32 resource file (.res) to be bundled into
266              the resulting assembly.
267
268       -win32icon:FILE
269              Attaches  the  icon  specified in FILE on the output into
270              the resulting assembly.
271
272       --     Use this to stop option parsing, and allow option-looking
273              parameters to be passed on the command line.
274

SPECIAL DEFINES

276       The  TRACE  and DEBUG defines have a special meaning to the com‐
277       piler.
278
279       By default calls to methods and properties in  the  System.Diag‐
280       nostics.Trace class are not generated unless the TRACE symbol is
281       defined (either through a "#define TRACE") in your source  code,
282       or by using the --define TRACE in the command line.
283
284       By  default  calls to methods and properties in the System.Diag‐
285       nostics.Debug class are not generated unless the DEBUG symbol is
286       defined  (either through a "#define DEBUG") in your source code,
287       or by using the --define DEBUG in the command line.
288
289       Note that the effect of defining TRACE and  DEBUG  is  a  global
290       setting, even if they are only defined in a single file.
291

DEBUGGING SUPPORT

293       When  use  the "--debug" or "-g" flag, MCS will create an assem‐
294       bler file FILE-debug.s containing  debugging  information  where
295       FILE is the name of the generated assembly. You need to run this
296       file through the assembler to get a  object  file  FILE-debug.o.
297       See  mono's  "--dwarf-plus"  argument  for details on how to use
298       this file.
299

NOTES

301       During compilation the MCS compiler defines the __MonoCS__  sym‐
302       bol,  this  can be used by pre-processor instructions to compile
303       Mono C# compiler specific code.   Please note that  this  symbol
304       is  only  to test for the compiler, and is not useful to distin‐
305       guish compilation or deployment platforms.
306

AUTHORS

308       The Mono C# Compiler  was  written  by  Miguel  de  Icaza,  Ravi
309       Pratap,  Martin  Baulig,  Marek  Safar  and  Raja Harinath.  The
310       development was funded by Ximian, Novell and Marek Safar.
311

LICENSE

313       The Mono Compiler Suite is released under the terms of  the  GNU
314       GPL.   Please  read the accompanying `COPYING' file for details.
315       Alternative licensing for the compiler is available from Novell.
316

SEE ALSO

318       mono(1), mint(1), sn(1)
319

BUGS

321       To report bugs in the compiler, you must file them  on  our  bug
322       tracking system, at: http://www.mono-project.com/Bugs
323

MAILING LIST

325       The   Mono   Mailing   lists   are  listed  at  http://www.mono-
326       project.com/Mailing_Lists
327

MORE INFORMATION

329       The  Mono   C#   compiler   was   developed   by   Novell,   Inc
330       (http://www.novell.com,  http)  and is based on the ECMA C# lan‐
331       guage            standard            available             here:
332       http://www.ecma.ch/ecma1/STAND/ecma-334.htm
333
334       The  home  page  for the Mono C# compiler is at http://www.mono-
335       project.com/CSharp_Compiler
336
337
338
339                                6 January 2001                          mcs(1)
Impressum