{"id":60,"date":"2008-12-23T18:25:56","date_gmt":"2008-12-23T22:25:56","guid":{"rendered":"http:\/\/www.compdigitec.com\/labs\/?p=60"},"modified":"2008-12-23T18:25:56","modified_gmt":"2008-12-23T22:25:56","slug":"linking-a-shared-assembly-in-the-mono-c-compiler","status":"publish","type":"post","link":"http:\/\/www.compdigitec.com\/labs\/2008\/12\/23\/linking-a-shared-assembly-in-the-mono-c-compiler\/","title":{"rendered":"Linking a shared assembly in the Mono C# compiler"},"content":{"rendered":"<p>If you wrote a class in C++ and wanted to use it in many applications, you could simple #include it in each application you wanted to use it in. But if you wrote a class in C# and wanted to use it in many applications, you cannot just #include it, because there is no #include in the C# language! The solution to this is to <strong>reference<\/strong> the library. This article will show you in easy steps:<\/p>\n<ol>\n<li>After you have written the class, compile it into a library with \u201c<strong>gmcs ClassXyz.cs -target:library<\/strong>\u201d (replace ClassXyz.cs with your class&#8217;s filename)<\/li>\n<li>The command above should generate a shared library\/assembly called ClassXyz.dll.<\/li>\n<li>Now you can compile the application with \u201c<strong>gmcs ProgramXyz.cs -reference:ClassXyz.dll<\/strong>\u201d.<\/li>\n<\/ol>\n<p>If you found this article useful or helpful, please help Compdigitec spread the word. Don&#8217;t forget to <a title=\"Subscribe to Compdigitec Labs\" href=\"\/labs\/feed\/\">subscribe to Compdigitec Labs<\/a> for more useful and interesting articles!<\/p>","protected":false},"excerpt":{"rendered":"<p>If you wrote a class in C++ and wanted to use it in many applications, you could simple #include it in each application you wanted to use it in. But if you wrote a class in C# and wanted to use it in many applications, you cannot just #include it, because there is no #include [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[351,352,353,289,341,349,350,343,342,862,333,340,345,344,347,346,348,354],"_links":{"self":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/60"}],"collection":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":0,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}