3

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.

Scott Deerwester
  • 3,503
  • 4
  • 33
  • 56

3 Answers3

1

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#.

Community
  • 1
  • 1
Scott Deerwester
  • 3,503
  • 4
  • 33
  • 56
1

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.

Sergey Zhukov
  • 1,342
  • 1
  • 13
  • 24
0

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.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • Thanks for the answer. Giving "-r:Gnu.Getopt" or "-r:Gnu.Getopt.dll" fails as well,though. Also, monodevelop doesn't find Gnu.Getopt in the list of references. It lists all of the other dll's in /usr/lib/mono/4.5. – Scott Deerwester Jan 22 '15 at 13:05