Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues building vips library from go

Tags:

macos

go

vips

I am trying to run/build a GoLang package that uses vips. When I try to compile the program I get this error: go build gopkg.in/h2non/bimg.v1: invalid flag in pkg-config --cflags: -Xpreprocessor

Here are my specs:

macOS Mojave Version 10.14.3
vips Version 8.7.4
go Version 1.11.5 darwin/amd64

I read some issues adding CGOALLOWEDFLAGS I've tried that also but no luck.

like image 207
cashews Avatar asked Dec 29 '25 04:12

cashews


1 Answers

CFLAGS is extra flags to give to the C compiler. (commonly used in make, see: https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html)

The gopkg.in/h2non/bimg.v1/vips.go uses pkg-config to generate the extra flags. It has -Xpreprocessor flag, which is not allowed by CGo (by default at the time of writing this).

For security reasons, only a limited set of flags are allowed, notably -D, -I, and -l. To allow additional flags, set CGO_CFLAGS_ALLOW to a regular expression matching the new flags. To disallow flags that would otherwise be allowed, set CGO_CFLAGS_DISALLOW to a regular expression matching arguments that must be disallowed. In both cases the regular expression must match a full argument: to allow -mfoo=bar, use CGO_CFLAGS_ALLOW='-mfoo.*', not just CGO_CFLAGS_ALLOW='-mfoo'. (See: https://golang.org/cmd/cgo/)

To allow -Xpreprocessor, you can set CGO_CFLAGS_ALLOW=-Xpreprocessor. For example:

CGO_CFLAGS_ALLOW=-Xpreprocessor go vet ./...
like image 75
Edward Samuel Avatar answered Dec 31 '25 18:12

Edward Samuel



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!