hel*_*978 2 c# windows mono gtk#
我试图让 Mono 和 Gtk# 在 Windows 上工作。
当我尝试运行 mcs hello.cs -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\gtk-sharp.dll"
我收到以下错误:
hello.cs(11,9): error CS0012: The type Atk.Implementor' is defined in an assemb ly that is not referenced. Consider adding a reference to assemblyatk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f' C:\Program Files (x86)\Mono\lib\gtk-sharp- 2.0\gtk-sharp.dll(与之前错误相关的符号位置)hello.cs(11,9): error CS0012: The type GLib.IWrapper' is defined in an assembly that is not referenced. Consider adding a reference to assemblyglib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f ' C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\gtk-sharp.dll(与先前错误相关的符号位置)编译失败:2 个错误,0 个警告
这是我的 hello.cs:
using Gtk;
using System;
class Hello
{
static void Main ()
{
Application.Init ();
Window window = new Window ("Hello Mono World");
window.Show ();
Application.Run ();
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试运行时:(如教程中所示)出现以下错误:
在 pkg-config 搜索路径中找不到包 gtk-sharp.2.0。也许您应该将包含 `gtk-sharp.2.0.pc' 的目录添加到 PKG_CONFIG_PATH 环境变量中 No package 'gtk-sharp.2.0' found error CS8027: Error running pkg-config。检查上面的输出。
我在网上没有找到任何东西,有人可以帮忙吗?
谢谢!
好的,问题似乎是 mcs 命令行选项 -pkg:gtk-sharp-2.0 在 Windows 下不起作用,在 Ubuntu 下它工作正常。
在 pkg-config 路径中有需要的文件 gtk-sharp-2.0.pc,如果我运行 pkg-configure 它也会找到 gtk-sharp 包。
如果有人知道如何在 Windows 中解决这个问题,那就太好了。
对于所有遇到与我相同问题的人,通过 -r 选项将所有需要的 dll 添加到 mcs:
mcs hello.cs -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0
\gtk-sharp.dll" -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\atk-sharp.dll"
-r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\glib-sharp.dll"
Run Code Online (Sandbox Code Playgroud)