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