Reputation: 161
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.
Upvotes: 2
Views: 3513
Reputation: 3968
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, setCGO_CFLAGS_ALLOW
to a regular expression matching the new flags. To disallow flags that would otherwise be allowed, setCGO_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
, useCGO_CFLAGS_ALLOW='-mfoo.*'
, not justCGO_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 ./...
Upvotes: 9