我如何告诉 mono 在哪里可以找到图书馆?

How do I tell mono where to find a library?

我正在尝试将 Gnu.Getopt 与单声道一起使用。按照这里的其他问题,我已经完成了:

% gacutil -i .../gnu.getopt.net-0.9.1/Gnu.Getopt/bin/Release/Gnu.Getopt.dll

哪个有效:

% gacutil -l | grep Gnu.Getopt
Gnu.Getopt, Version=0.9.1.24287, Culture=neutral, PublicKeyToken=d014b4ccdc53511a

但是单声道找不到:

% grep Gnu Program.cs
using Gnu.Getopt;
% mcs Program.cs
Program.cs(4,7): error CS0246: The type or namespace name `Gnu' could not be found. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings

提供 DLL 的显式路径工作正常:

% mcs -r:.../gnu.getopt.net-0.9.1/Gnu.Getopt/bin/Release/Gnu.Getopt.dll Program.cs
%

我错过了什么?

更新

我注意到 /usr/lib/mono/4.5/usr/lib/mono/gac 中的所有内容都有符号 link(例如 System.Core.dll -> ../gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll)。我在 Gnu.Getopt.dll 中插入了符号 link,但症状仍然存在。

根据mcs documentation编译时默认引用的唯一程序集:

mscorlib.dll
System.dll

Microsoft 的 CSC 编译器具有类似的行为,默认情况下会引用一组程序集,但需要将其他程序集传递给编译器,即使是那些在 GAC 中的程序集。

在单声道列表上发帖并进一步搜索后,答案似乎是 "don't use Gnu.Getopt"; use Ndesk.Options instead as per GetOpt library for C#

如果您正在寻找将命令行选项解析器与单声道一起使用的常用方法,则有一个文件 Options.cs 位于 /usr/lib/mono-source-libs(将 /usr 更改为单声道所在的前缀已安装)。 要引用系统上安装的文件的最新版本,您可以在编译器中使用 -pkg:mono-options 命令行选项(-pkgmcs 编译器选项,它允许引用系统包)。 或者您可以将文件复制到您的项目并像使用任何其他 cs 文件一样使用它。