Compiling C# Souce Code as a Dynamic Link Library

The following is the command to compile dllsource.cs as a dynamic link library instead of the executable file:

$ mcs /target:library dllsource.cs

We can also specify a different name of the binary with the /out option. For example:

$ mcs /target:library /out:mylibrary.dll dllsource.cs

Finally, if we want to compile a souce which depends on a dll file, we need to use the /reference option.

$ mcs example.cs /reference:mylibrary.dll

Note: mcs is the mono compiler. If you use Microsoft C# compiler, just replace mcs with csc.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s