Newbie Question: GTK# (Mono) on OSX

落爺英雄遲暮 提交于 2019-12-05 03:11:25

Quick and dirty solution:

cd /usr/local/bin
sudo ln -s /Library/Frameworks/Mono.framework/Commands/pkg-config ./pkg-config

Now your gmcs -pkg:... command will work.

Background: I hit this exact problem on a new Mac and a fresh install of Mono. Left me scratching my head for a few days until I took a close look at the error message:

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

It's saying it couldn't run the program, so I did a

which pkg-config

That came up blank, so I thought probably it couldn't run it because it wasn't in the path. And that turned out to be it.

You have a mixed setup.

The Gtk in /opt/local/var/macports did not come from Mono's installer for OSX, you probably got it earlier from macports. The Mono installer places its files under /Library/Frameworks/Mono.framework/

Chances are, you have something else on your path, since it works out of the box after I installed the Mono.Framework from the Mono web site (with the command line example that you have above).

Using MonoDevelop might make things easier, but here is how it references gtk# while compiling (note that it references the assembly straight from the GAC):

gmcs test.cs -r:/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll

You'll usually also need to include references to gdk-sharp and pango-sharp and glib-sharp, btw.

Note in the path that the framework version is "Current", which makes the command a little more future-proof.

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