linux - 使用 MONO 编译 - 引用 C# 库的 C#?

标签 linux mono compiler-construction

我有一个 C# 库 (DLL)

//  ProgramLib.cs //
using System;

namespace ProgramLibrary
{
    public class Lib
    {
        public Lib()
        {
            Console.WriteLine("Lib Created");
        }
    }
}

我有以下控制台程序

//  Program.cs //
using System;
using ProgramLibrary;

class MainClass
{
    public static void Main (string[] args)
    {
        ProgramLibrary.Lib lib = new ProgramLibrary.Lib();
    }
}

在linux环境下,如果两个文件都在同一个目录下

引用 ProgramLib.cs 编译 Program.cs 的 Mono 编译器 (mcs) 命令是什么?

谢谢大家!!

最佳答案

先将ProgramLib编译成ProgramLib.dll,然后再引用:

$ gmcs -t:library ProgramLib.cs
$ gmcs -r:ProgramLib.dll Program.cs

关于linux - 使用 MONO 编译 - 引用 C# 库的 C#?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1496676/

相关文章:

Java 泛型 Eclipse 编译器错误?

linux - 重用弹性 IP 时出现 AWS Instance SSH 连接问题

linux - cd//是什么意思(将目录更改为//)

.net - 单声道对于 Mac OS X 来说足够快吗?

asp.net - 在 Mono 上使用 F# 和 ASP.NET Webforms

java - GWT 开发模式不编译 Web 应用程序

c - 高科技C编译器: #define: "taking the address of this object is illegal"

linux - 更改 emacs 字体(菜单中没有 "set default font"选项;.emacs 脚本不起作用)

python - 两台电脑之间通过ssh传输文件

c# - Jay,单声道 C# 编译器和更改语法