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