无法为Golang构建Magick。

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

unable to build magick for golang

问题

我正在按照这个文档来构建Go Imagick库。

当我运行以下命令时:

go build -tags no_pkgconfig imagick

它会抛出以下异常:

# imagick
src/imagick/affine_matrix.go:8:29: fatal error: wand/MagickWand.h: 没有那个文件或目录
compilation terminated

为了解决这个问题,我也安装了以下包,因为很多人建议这样做来解决错误。但是它也没有起作用。

sudo apt-get install libmagickwand-dev libmagickcore-dev imagemagick

此外,当我运行go build imagick时,它会抛出以下错误:

# imagick
could not determine kind of name for C.FlattenAlphaChannel
could not determine kind of name for C.RemoveAlphaChannel

运行pkg-config --cflags --libs MagickWand的输出是正确的:

-fopenmp -I/usr/include/ImageMagick  -lMagickWand -lMagickCore

ImageMagick只安装到了这个路径(/usr/include/ImageMagick)。

英文:

I am following this document for building the Go Imagick library.

When i ran the following command

go build -tags no_pkgconfig imagick

It throws the following exception :

# imagick
src/imagick/affine_matrix.go:8:29: fatal error: wand/MagickWand.h: No such file or directory
compilation terminated

Now to resolve that i have also installed the following packages as many people suggested to resolve the error. But it didn't work either.

sudo apt-get install libmagickwand-dev libmagickcore-dev imagemagick

Moreover, when i run go build imagick
It throws the following error :

# imagick
could not determine kind of name for C.FlattenAlphaChannel
could not determine kind of name for C.RemoveAlphaChannel

Output of pkg-config --cflags --libs MagickWand gives the correct output

-fopenmp -I/usr/include/ImageMagick  -lMagickWand -lMagickCore

ImageMagick is installed to this path(/usr/include/ImageMagick) only.

答案1

得分: 2

根据他们的文档提到,必须使用no_pkgconfig标签,并手动设置GCO_CFLAGSCGO_LDFLAGS。所以可以尝试以下方式:

export CGO_CFLAGS="$(pkg-config --cflags MagickWand)"
export CGO_LDFLAGS="$(pkg-config --libs MagickWand)"
go build -tags no_pkgconfig
英文:

Their docs mention that no_pkgconfig must be used with manually set GCO_CFLAGS and CGO_LDFLAGS. So something like this should work:

export CGO_CFLAGS="$(pkg-config --cflags MagickWand)"
export CGO_LDFLAGS="$(pkg-config --libs MagickWand)"
go build -tags no_pkgconfig

答案2

得分: 1

根据问题跟踪器的#68,提到你正在使用一个过于旧的ImageMagick版本,该版本早于主分支测试过的版本。你的Linux发行版比当前可用的稳定版本要旧。

你应该手动安装一个更新的ImageMagick,并删除apt中的旧版本。或者使用一些允许你管理多个版本的解决方案。

英文:

As mentioned on #68 of the issue tracker, you are using way too old of a version of ImageMagick, which predates the versions that were tested for the master branch. Your Linux distro is older than the current available stable release.

You should manually install a newer ImageMagick, and remove the, one from apt. Or use some solution that allows you to manage multiple versions.

huangapple
  • 本文由 发表于 2016年1月13日 18:46:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/34764612.html
匿名

发表评论

匿名网友

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

确定