问题
I downloaded Mono and installed it on Win 7 64bit
I went to this site to follow the instructions http://www.mono-project.com/Mono_Basics
I opened up the mono command prompt and compiled and ran the console hello world
then I tried to compile the windowed hello world example with
gmcs hello.cs -pkg:gtk-sharp-2.0
and I get this
C:\Code\NoControl\Mono>gmcs hello.cs -pkg:gtk-sharp-2.0
error CS0006: Metadata file `C:/PROGRA\~2/MONO-2\~1.8/lib/mono/gtk-sharp-2.0/pango-sharp.dll' could not be found
error CS0006: Metadata file `C:/PROGRA\~2/MONO-2\~1.8/lib/mono/gtk-sharp-2.0/atk-sharp.dll' could not be found
error CS0006: Metadata file `C:/PROGRA\~2/MONO-2\~1.8/lib/mono/gtk-sharp-2.0/gdk-sharp.dll' could not be found
error CS0006: Metadata file `C:/PROGRA\~2/MONO-2\~1.8/lib/mono/gtk-sharp-2.0/gtk-sharp.dll' could not be found
error CS0006: Metadata file `C:/PROGRA\~2/MONO-2\~1.8/lib/mono/gtk-sharp-2.0/glib-sharp.dll' could not be found
Compilation failed: 5 error(s), 0 warnings
How do I fix this?
This is the similar to the question here cannot compile hello.cs for gtk# using mono command prompt which was not answered.
- Does -pkg work on Windows?
- Do I have to download something extra?
- The abbreviated path mentions ~1.8/ should it say something like ~10.8 being that my version of mono is 2.10.8?
回答1:
These were helpful answers for pointing out the root cause of the problem. However, the simplest solution by far is to install Mono into a folder that doesn't have spaces in the name. While installing, just select something like "C:\SDK\Mono". Problem solved, and no funky work-arounds necessary.
回答2:
A work-around I have found to work on Windows 7 where Mono has been installed as a subdirectory of 'Program Files' is to create a folder in the root of C: to hold directory links (for instance called MonoLinks.. NB no space in the name) and then, from a command prompt go into this directory and create a Directory Junction, giving it a name that does not include a space.
C:\MonoLinks>mklink /J Mono "C:\Program Files\Mono-2.10.8"
This has the effect of creating a traversable directory (link) named Mono that will not only show the contents of the Mono installation but will be accessible to programs without being translated to its original pathname. This could, just as easily, be created in the root of C: but having a generic folder (MonoLinks) there allows for additional links, if needed, to be created within it without cluttering up the root of C:.
The next thing (which had to be done anyway as the PATH environment variable was not updated during the installation) is to update the PATH environment variable so that it points to the bin directory within the installation.
Within Control Panel, User Accounts, select Change My Environment Variables and edit the PATH variable to include C:\MonoLinks\Mono\bin
(i.e add semicolon and the path to the end of the PATH property's text).
回答3:
-pkg
seems to be flawed on Windows. On a clean command prompt, if you put Program Files\Mono\bin
on your PATH, gmcs
will choke on the syntax and will give errors regarding Files\Mono\...
, indicating an error related to the spaces in the pathname. If you put PROGRA~1\MONO\bin
on your PATH or use the Mono command prompt, it will choke and give errors regarding PROGRA\~1/MONO/...
, indicating an error related to tildes (etc.) and escaping them.
Note that although I've given 32-bit examples, there is no reason why this shouldn't apply to 64-bit editions, PROGRA~2
and Program Files (x86)
.
A workaround I've found is to give individual -r[eference]
parameters to gmcs based on the information pkg-config returns, using full paths. Try:
gmcs hello.cs -r:C:/PROGRA~2/MONO-2~1.8/lib/mono/gtk-sharp-2.0/gtk-sharp.dll
-r:C:/PROGRA~2/MONO-2~1.8/lib/mono/gtk-sharp-2.0/gdk-sharp.dll
...
or better yet:
gmcs hello.cs -r:"C:\Program Files (x86)\Mono-2.10.8\lib\mono\..." -r:"..."
(i.e. full paths)
If you're using NAnt, try removing <pkg-references/>
and adding:
<include name="C:\Program Files\Mono\lib\mono\gtk-sharp-2.0\gtk-sharp.dll" />
<include name="C:\Program Files\Mono\lib\mono\gtk-sharp-2.0\gdk-sharp.dll" />
...
under <references/>
.
Please excuse my use of inconsistent and incomplete path names; this answer is meant to be a guide, not a copy-paste-solution.
来源:https://stackoverflow.com/questions/10630051/mono-development-environment-on-win-7-64bit-gmcs-hello-cs-pkggtk-sharp-2-0-can