Scott Deerwester
Scott Deerwester

Reputation: 3977

How do I tell mono where to find a library?

I'm trying to use Gnu.Getopt with mono. Following other questions here, I have done:

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

which works:

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

but mono can't find it:

% 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

Giving an explicit path to the DLL works fine:

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

What am I missing?

Update

I noticed that /usr/lib/mono/4.5 has symbolic links to everything in /usr/lib/mono/gac (e.g. System.Core.dll -> ../gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll). I inserted a symbolic link to Gnu.Getopt.dll, but the symptoms persist.

Upvotes: 3

Views: 2208

Answers (3)

Sergey Zhukov
Sergey Zhukov

Reputation: 1372

If you looking a common way to use command-line options parser with mono, there is a file Options.cs located in /usr/lib/mono-source-libs (change /usr to the prefix where your mono is installed). To reference recent version of the file installed on the system you can use -pkg:mono-options command-line options in compiler (-pkg is the mcs compiler options, which allows to reference system packages). Or you can just copy the file to your project and use it like any other cs file.

Upvotes: 1

Scott Deerwester
Scott Deerwester

Reputation: 3977

After posting on the mono list and hunting a bit further, the answer appears to be "don't use Gnu.Getopt"; use Ndesk.Options instead as per GetOpt library for C#.

Upvotes: 1

Matt Ward
Matt Ward

Reputation: 47907

According to the mcs documentation the only assemblies that are referenced by default when compiling:

mscorlib.dll
System.dll

Microsoft's CSC compiler has similar behaviour where a set of assemblies are referenced by default but other assemblies need to be passed to the compiler, even those that are in the GAC.

Upvotes: 0

Related Questions