cannot compile gtk# example

南笙酒味 提交于 2020-01-04 15:29:48

问题


I'm trying to compile the "GTK# Hello World" example at http://mono-project.com/Mono_Basics in Windows 7 (64bits). I'm getting this error:

error CS8027: Couldn't run pkg-config: ApplicationName='pkg-config', CommandLine ='--libs gtk-sharp-2.0', CurrentDirectory=''

I have successfully compiled and run the "Console Hello World" example.

I have installed Mono-2.10.8.

Thanks in advance for your help


回答1:


I tried to compile a GTK# example in a Windows 7 with Mono 2.10.8 and the options you used with the compiler, so i have the same error then i tried to reference each assembly by hand so it works fine.

Here is the full command, i tested in a Mono 2-10.8 comman prompt.

gmcs ButtonApp.cs -r:C:/PROGRA~2/MONO-2~1.8/lib/mono/gtk-sharp-2.0/pango-sharp.dll,C:/PROGRA~2/MONO-2~1.8/lib/mono/gtk-sharp-2.0/atk-sharp.dll,C:/PROGRA~2/MONO-2~1.8/lib/mono/gtk-sharp-2.0/gdk-sharp.dll,C:/PROGRA~2/MONO-2~1.8/lib/mono/gtk-sharp-2.0/gtk-sharp.dll

I hope this can helps




回答2:


You were trying to use pkg-config which you do not have. pkg-config with --libs turns specified packages (like gtk-sharp-2.0 in your case) into references to libraries. If you don't want to install pkg-config, you have two options:

  • manually reference needed libraries with compiler options;
  • create a project with these libraries referenced.

I recommend the second option, as compiling by specifying all sources and references directly could be good for hello-world examples, but not for the something bigger. You would make your own script to compile the project, so why not use something designed just for that - like xbuild or make. MonoDevelop should contain empty Gtk# project template.



来源:https://stackoverflow.com/questions/8835352/cannot-compile-gtk-example

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!