mcs.1 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. .de Sp \" Vertical space (when we can't use .PP)
  2. .if t .sp .5v
  3. .if n .sp
  4. ..
  5. .TH mcs 1 "6 January 2001"
  6. .SH NAME
  7. mcs, gmcs, smcs \- Mono C# Compiler (1.0, 2.0, Moonlight)
  8. .SH SYNOPSIS
  9. .B mcs
  10. [option] [source-files]
  11. .SH DESCRIPTION
  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.
  17. .PP
  18. The
  19. .I mcs
  20. compiler is used to compile against the 1.x profile and implements
  21. C# 1.0 and parts of C# 2.0 and C# 3.0 specification which do not depend
  22. on generics.
  23. .PP
  24. The
  25. .I gmcs
  26. compiler is used to compile against the 2.0 profile and implements
  27. the complete C# 3.0 specification.
  28. .PP
  29. The
  30. .I smcs
  31. compiler is used to compile against the Silverlight/Moonlight profile.
  32. This profile is designed to be used for creating Silverlight/Moonlight
  33. applications that will run on a web browser. The API exposed by this
  34. profile is a small subset of the 3.5 API (even if it is commonly
  35. referred as the 2.1 API, this API is a small subset of 2.0 with a few
  36. extensions).
  37. .PP
  38. See the section on packages for more information.
  39. .PP
  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.
  46. .PP
  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.
  53. .PP
  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.
  59. .PP
  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.
  66. .PP
  67. .SH OPTIONS
  68. .TP
  69. .I \-\-about
  70. Displays information about the Mono C# compiler
  71. .TP
  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
  75. .TP
  76. .I -checked, -checked+
  77. Sets the default compilation mode to `checked'. This makes all
  78. the math operations checked (the default is unchecked).
  79. .TP
  80. .I -checked-
  81. Sets the default compilation mode to `unchecked'. This makes all
  82. the math operations unchecked (this is the default).
  83. .TP
  84. .I -clscheck-, -clscheck+
  85. Disables or enables the Common Language Specification (CLS) checks (it
  86. is enabled by default).
  87. .Sp
  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).
  92. .TP
  93. .I -codepage:ID
  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.
  98. .Sp
  99. Other popular encodings are 28591 (Latin1), 1252 (iso-8859-1) and 65001 (UTF-8).
  100. .Sp
  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.
  104. .TP
  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
  109. attribute.
  110. .TP
  111. .I \-debug, \-debug+
  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
  115. resource.
  116. .TP
  117. .I \-debug-
  118. Do not generate debugging information.
  119. .TP
  120. .I \-delaysign+
  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
  127. attributes.
  128. .TP
  129. .I \-delaysign-
  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.
  134. .TP
  135. .I \-doc:FILE
  136. Extracts the C#/XML documentation from the source code and stores in in
  137. the given FILE.
  138. .TP
  139. .I \-\-fatal
  140. This is used for debugging the compiler. This makes the error emission
  141. generate an exception that can be caught by a debugger.
  142. .TP
  143. .I \-keyfile:KEYFILE
  144. Strongname (sign) the output assembly using the key pair present in
  145. the specified strong name key file (snk). A full key pair is required
  146. by default (or when using delaysign-). A file containing only the
  147. public key can be used with delaysign+. The option is equivalent to
  148. including [assembly: AssemblyKeyFile ("KEYFILE")] in your source code.
  149. Compiler option takes precedence over the attributes.
  150. .TP
  151. .I \-keycontainer:CONTAINER
  152. Strongname (sign) the output assembly using the key pair present in
  153. the specified container. Note that delaysign+ is ignored when using
  154. key containers. The option is equivalent to including [assembly:
  155. AssemblyKeyName ("CONTAINER")] in your source code. Compiler option
  156. takes precedence over the attributes.
  157. .TP
  158. .I \-langversion:TEXT
  159. The option specifies the version of the language to use. The feature
  160. set is different in each C# version. This switch can be used to force
  161. the compiler to allow only a subset of the features.
  162. The possible values are:
  163. .RS
  164. .ne 8
  165. .TP
  166. .I "Default"
  167. Instruct compiler to use the latest version. Equivalent is to omit the
  168. switch (this currently defaults to the C# 3.0 language specification).
  169. .TP
  170. .I "ISO-1"
  171. Restrict compiler to use only first ISO standardized features.
  172. The usage of features such as generics, static classes, anonymous
  173. methods will lead to error.
  174. .TP
  175. .I "ISO-2"
  176. Restrict compiler to use only the second ISO standardized features.
  177. This allows the use of generics, static classes, iterators and
  178. anonymous methods for example.
  179. .PP
  180. Notice that this flag only controls the language features available to
  181. the programmer, it does not control the kind of assemblies produced.
  182. Programs compiled with mcs will reference the 1.1 APIs, Programs
  183. compiled with gmcs reference the 2.0 APIs.
  184. .ne
  185. .RE
  186. .TP
  187. .I -lib:PATHLIST
  188. Each path specified in the comma-separated list will direct the
  189. compiler to look for libraries in that specified path.
  190. .TP
  191. .I \-L PATH
  192. Directs the compiler to look for libraries in the specified path.
  193. Multiple paths can be provided by using the option multiple times.
  194. .TP
  195. .I \-main:CLASS
  196. Tells the compiler which CLASS contains the entry point. Useful when
  197. you are compiling several classes with a Main method.
  198. .TP
  199. .I \-nostdlib, -nostdlib+
  200. Use this flag if you want to compile the core library. This makes the
  201. compiler load its internal types from the assembly being compiled.
  202. .TP
  203. .I \-noconfig, \-noconfig+
  204. Disables the default compiler configuration to be loaded. The
  205. compiler by default has references to the system assemblies.
  206. .TP
  207. .I \-nowarn:WARNLIST
  208. Makes the compiler ignore warnings specified in the comma-separated
  209. list WARNLIST>
  210. .TP
  211. .I -optimize, -optimize+, -optimize-
  212. Controls whether to perform optimizations on the code. -optimize and
  213. -optimize+ will turn on optimizations, -optimize- will turn it off.
  214. The default in mcs is to optimize+.
  215. .TP
  216. .I -out:FNAME, -o FNAME
  217. Names the output file to be generated.
  218. .TP
  219. .I \-\-parse
  220. Used for benchmarking. The compiler will only parse its input files.
  221. .TP
  222. .I \-pkg:package1[,packageN]
  223. Reference assemblies for the given packages.
  224. .Sp
  225. The compiler will invoke pkg-config --libs on the set of packages
  226. specified on the command line to obtain libraries and directories to
  227. compile the code.
  228. .Sp
  229. This is typically used with third party components, like this:
  230. .nf
  231. $ mcs -pkg:gtk-sharp demo.cs
  232. .fi
  233. .RS
  234. .ne 8
  235. .TP
  236. .I \-pkg:dotnet
  237. This will instruct the compiler to reference the System.* libraries
  238. available on a typical dotnet framework installation, notice that this
  239. does not include all of the Mono libraries, only the System.* ones. This
  240. is a convenient shortcut for those porting code.
  241. .TP
  242. .I \-pkg:olive
  243. Use this to reference the "Olive" libraries (the 3.0 and 3.5 extended
  244. libraries).
  245. .TP
  246. .I \-pkg:silver
  247. References the assemblies for creating Moonlight/Silverlight
  248. applications. This is automatically used when using the
  249. .I smcs
  250. compiler, but it is here when developers want to use it with the
  251. .I gmcs
  252. compiler.
  253. .TP
  254. .I \-pkg:silverdesktop
  255. Use this option to create Moonlight/Silverlight applications that
  256. target the desktop. This option allows developers to consume the
  257. Silverlight APIs with the full 2.0 profile API available to them,
  258. unlike
  259. .I smcs
  260. it gives full access to all the APIs that are part of Mono. The only
  261. downside is that applications created with silverdesktop will not run
  262. on the browser. Typically these applications will be launched
  263. with the
  264. .I mopen
  265. command line tool.
  266. .TP
  267. For more details see the PACKAGE section in this document
  268. .ne
  269. .RE
  270. .TP
  271. .I -resource:RESOURCE[,ID]
  272. Embeds to the given resource file. The optional ID can be used to
  273. give a different name to the resource. If not specified, the resource
  274. name will be the file name.
  275. .TP
  276. .I -linkresource:RESOURCE[,ID]
  277. Links to the specified RESOURCE. The optional ID can be used to give
  278. a name to the linked resource.
  279. .TP
  280. .I -r:ASSEMBLY1[,ASSEMBLY2], \-reference ASSEMBLY1[,ASSEMBLY2]
  281. Reference the named assemblies. Use this to use classes from the named
  282. assembly in your program. The assembly will be loaded from either the
  283. system directory where all the assemblies live, or from the path
  284. explicitly given with the -L option.
  285. .Sp
  286. You can also use a semicolon to separate the assemblies instead of a
  287. comma.
  288. .TP
  289. .I -reference:ALIAS=ASSEMBLY
  290. Extern alias reference support for C#.
  291. .Sp
  292. If you have different assemblies that provide the same types, the
  293. extern alias support allows you to provide names that your software
  294. can use to tell those appart. The types from ASSEMBLY will be
  295. exposed as ALIAS, then on the C# source code, you need to do:
  296. .Sp
  297. .nf
  298. extern alias ALIAS;
  299. .fi
  300. To bring it into your namespace. For example, to cope with two
  301. graphics libraries that define "Graphics.Point", one in
  302. "OpenGL.dll" and one in "Postscript.dll", you would invoke the
  303. compiler like this:
  304. .Sp
  305. .nf
  306. mcs -r:Postscript=Postscript.dll -r:OpenGL=OpenGL.dll
  307. .fi
  308. .Sp
  309. And in your source code, you would write:
  310. .Sp
  311. .nf
  312. extern alias Postscript;
  313. extern alias OpenGL;
  314. class X {
  315. // This is a Graphics.Point from Postscrip.dll
  316. Postscript.Point p = new Postscript.Point ();
  317. // This is a Graphics.Point from OpenGL.dll
  318. OpenGL.Point p = new OpenGL.Point ();
  319. }
  320. .fi
  321. .TP
  322. .I \-recurse:PATTERN, --recurse PATTERN
  323. Does recursive compilation using the specified pattern. In Unix the
  324. shell will perform globbing, so you might want to use it like this:
  325. .PP
  326. .nf
  327. $ mcs -recurse:'*.cs'
  328. .fi
  329. .TP
  330. .I \-\-shell
  331. Starts up the compiler in interactive mode, providing a C# shell for
  332. statements and expressions. A shortcut is to use the
  333. .I csharp
  334. command directly.
  335. .TP
  336. .I \-\-stacktrace
  337. Generates a stack trace at the time the error is reported, useful for
  338. debugging the compiler.
  339. .TP
  340. .I \-target:KIND, \-t:KIND
  341. Used to specify the desired target. The possible values are: exe
  342. (plain executable), winexe (Windows.Forms executable), library
  343. (component libraries) and module (partial library).
  344. .TP
  345. .I \-\-timestamp
  346. Another debugging flag. Used to display the times at various points
  347. in the compilation process.
  348. .TP
  349. .I \-unsafe, -unsafe+
  350. Enables compilation of unsafe code.
  351. .TP
  352. .I \-v
  353. Debugging. Turns on verbose yacc parsing.
  354. .TP
  355. .I \-\-version
  356. Shows the compiler version.
  357. .TP
  358. .I \-warnaserror, \-warnaserror+
  359. Treat warnings as errors.
  360. .TP
  361. .I \-warnaserror:W1,[Wn]
  362. Treats one or more compiler warnings as errors.
  363. .TP
  364. .I \-warn:LEVEL
  365. Sets the warning level. 0 is the lowest warning level, and 4 is the
  366. highest. The default is 4.
  367. .TP
  368. .I \-win32res:FILE
  369. Specifies a Win32 resource file (.res) to be bundled into the
  370. resulting assembly.
  371. .TP
  372. .I \-win32icon:FILE
  373. Attaches the icon specified in FILE on the output into the resulting
  374. assembly.
  375. .TP
  376. .I \-\-
  377. Use this to stop option parsing, and allow option-looking parameters
  378. to be passed on the command line.
  379. .PP
  380. .SH PACKAGES
  381. Depending on the invocation for the C# compiler (mcs, gmcs, or smcs)
  382. you will get a default set of libraries and versions of those
  383. libraries that are referenced.
  384. .PP
  385. The compiler uses the library path to locate libraries, and is able to
  386. reference libraries from a particular package if that directory is
  387. used. To simplify the use of packages, the C# compiler includes the
  388. -pkg: command line option that is used to load specific collections of
  389. libraries.
  390. .PP
  391. Libraries visible to the compiler are stored relative to the
  392. installation prefix under PREFIX/lib/mono/ called the PACKAGEBASE and the
  393. defaults for mcs, gmcs and smcs are as follows:
  394. .TP
  395. .I mcs
  396. References the PACKAGEBASE/1.0 directory
  397. .TP
  398. .I gmcs
  399. References the PACKAGEBASE/2.0 directory
  400. .TP
  401. .I smcs
  402. References the PACKAGEBASE/2.1 directory
  403. .PP
  404. Those are the only runtime profiles that exist. Although other
  405. directories exist (like 3.0 and 3.5) those are not really runtime
  406. profiles, they are merely placeholders for extra libraries that build
  407. on the 2.0 foundation.
  408. .PP
  409. Software providers will distribute software that is installed relative
  410. to the PACKAGEBASE directory. This is integrated into the
  411. .I gacutil
  412. tool that not only installs public assemblies into the Global Assembly
  413. Cache (GAC) but also installs them into the PACKAGEBASE/PKG directory
  414. (where PKG is the name passed to the -package flag to gacutil).
  415. .PP
  416. As a developer, if you want to consume the Gtk# libraries, you would
  417. invoke the compiler like this:
  418. .nf
  419. $ mcs -pkg:gtk-sharp-2.0 main.cs
  420. .fi
  421. The -pkg: option instructs the compiler to fetch the definitions for
  422. gtk-sharp-2.0 from pkg-config, this is equivalent to passing to the C#
  423. compiler the output of:
  424. .nf
  425. $ pkg-config --libs gtk-sharp-2.0
  426. .fi
  427. Usually this merely references the libraries from PACKAGEBASE/PKG.
  428. .PP
  429. Although there are directory names for 3.0 and 3.5, that does not mean
  430. that there are 3.0 and 3.5 compiler editions or profiles. Those are
  431. merely new libraries that must be manually referenced either with the
  432. proper -pkg: invocation, or by referencing the libraries directly.
  433. .PP
  434. .SH SPECIAL DEFINES
  435. The
  436. .B TRACE
  437. and
  438. .B DEBUG
  439. defines have a special meaning to the compiler.
  440. .PP
  441. By default calls to methods and properties in the
  442. System.Diagnostics.Trace class are not generated unless the TRACE
  443. symbol is defined (either through a "#define TRACE") in your source
  444. code, or by using the
  445. .I "--define TRACE"
  446. in the command line.
  447. .PP
  448. By default calls to methods and properties in the
  449. System.Diagnostics.Debug class are not generated unless the DEBUG
  450. symbol is defined (either through a "#define DEBUG") in your source
  451. code, or by using the
  452. .I "--define DEBUG"
  453. in the command line.
  454. .PP
  455. Note that the effect of defining TRACE and DEBUG is a global setting,
  456. even if they are only defined in a single file.
  457. .PP
  458. .SH DEBUGGING SUPPORT
  459. When using the "-debug" flag, MCS will generate a file with the
  460. extension .mdb that contains the debugging information for the
  461. generated assembly. This file is consumed by the Mono debugger (mdb).
  462. .SH ENVIRONMENT VARIABLES
  463. .TP
  464. .I "MCS_COLORS"
  465. If this variable is set, it contains a string in the form
  466. "foreground,background" that specifies which color to use to display
  467. errors on some terminals.
  468. .Sp
  469. The background is optional and defaults to your terminal current
  470. background. The possible colors for foreground are:
  471. .B black, red, brightred, green, brightgreen, yellow, brightyellow,
  472. blue, brightblue, magenta, brightmagenta, cyan, brightcyan, grey,
  473. white and brightwhite.
  474. .Sp
  475. The possible colors for background are: black, red, green, yellow,
  476. blue, magenta, cyan, grey and white.
  477. .Sp
  478. For example, you could set these variable from your shell:
  479. .nf
  480. export MCS_COLORS
  481. MCS_COLORS=errors=brightwhite,red
  482. .fi
  483. .Sp
  484. You can disable the built-in color scheme by setting this variable to
  485. "disable".
  486. .SH NOTES
  487. During compilation the MCS compiler defines the __MonoCS__ symbol,
  488. this can be used by pre-processor instructions to compile Mono C#
  489. compiler specific code. Please note that this symbol is only to test
  490. for the compiler, and is not useful to distinguish compilation or
  491. deployment platforms.
  492. .SH AUTHORS
  493. The Mono C# Compiler was written by Miguel de Icaza, Ravi Pratap,
  494. Martin Baulig, Marek Safar and Raja Harinath. The development was
  495. funded by Ximian, Novell and Marek Safar.
  496. .PP
  497. .SH LICENSE
  498. The Mono Compiler Suite is released under the terms of the GNU GPL or
  499. the MIT X11. Please read the accompanying `COPYING' file for details.
  500. Alternative licensing for the compiler is available from Novell.
  501. .PP
  502. .SH SEE ALSO
  503. csharp(1), mdb(1), mono(1), mopen(1), mint(1), pkg-config(1),sn(1)
  504. .PP
  505. .SH BUGS
  506. To report bugs in the compiler, you must file them on our bug tracking
  507. system, at:
  508. http://www.mono-project.com/Bugs
  509. .SH MAILING LIST
  510. The Mono Mailing lists are listed at http://www.mono-project.com/Mailing_Lists
  511. .SH MORE INFORMATION
  512. The Mono C# compiler was developed by Novell, Inc
  513. (http://www.novell.com, http) and is based on the
  514. ECMA C# language standard available here:
  515. http://www.ecma.ch/ecma1/STAND/ecma-334.htm
  516. .PP
  517. The home page for the Mono C# compiler is at http://www.mono-project.com/CSharp_Compiler