Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to build magick for golang

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.

like image 306
Naresh Avatar asked Dec 09 '25 00:12

Naresh


1 Answers

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
like image 143
Ainar-G Avatar answered Dec 10 '25 19:12

Ainar-G



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!