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