cgo和pkg-config

huangapple go评论87阅读模式
英文:

cgo and pkg-config

问题

我想使用cgo运行GraphicsMagick。

/*
#cgo pkg-config: GraphicsMagick-config

#include <magick/api.h>

static int gm(int argc, char **argv) {
	int status;
	status = GMCommand(argc, argv);
    return 1-status;
}
*/

然后我运行'go install',它显示:

# pkg-config --cflags GraphicsMagick-config
Package GraphicsMagick-config was not found in the pkg-config search path.
Perhaps you should add the directory containing `GraphicsMagick-config.pc'
to the PKG_CONFIG_PATH environment variable
No package 'GraphicsMagick-config' found
exit status 1

但是我在shell中运行'pkg-config GraphicsMagick-config'是可以的。

英文:

I want to run GraphicsMagick with cgo.

/*
#cgo pkg-config: GraphicsMagick-config

#include &lt;magick/api.h&gt;

static int gm(int argc, char **argv) {
	int status;
	status = GMCommand(argc, argv);
    return 1-status;
}
*/

then I run 'go install', it says:

# pkg-config --cflags GraphicsMagick-config
Package GraphicsMagick-config was not found in the pkg-config search path.
Perhaps you should add the directory containing `GraphicsMagick-config.pc&#39;
to the PKG_CONFIG_PATH environment variable
No package &#39;GraphicsMagick-config&#39; found
exit status 1

but I run 'pkg-config GraphicsMagick-config' in shell and it's ok.

答案1

得分: 2

GraphicsMagick-config脚本是一个独立的程序,而不是一个pkg-config资源,这解释了问题的原因。

此外,使用非选项参数运行pkg-config似乎会失败,而不会打印错误消息,这可能会让你感到困惑。

除了这个脚本之外,该库还安装了一个GraphicsMagick.pc数据文件供pkg-config使用。所以你应该能够通过以下方式使你的代码运行起来:

#cgo pkg-config: GraphicsMagick
英文:

The GraphicsMagick-config script is a separate program rather than a pkg-config resource, which explains the problem.

Also, running pkg-config with a non-option argument seems to fail without printing an error message, which might have confused you.

In addition to this script though, the library does install a GraphicsMagick.pc data file for pkg-config. So you should be able to get your code running with:

#cgo pkg-config: GraphicsMagick

huangapple
  • 本文由 发表于 2013年3月13日 18:12:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/15382325.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定