从 go 构建 vips 库的问题
Issues building vips library from go
我正在尝试 run/build 使用 vips 的 GoLang 包。当我尝试编译程序时出现此错误:
go build gopkg.in/h2non/bimg.v1: invalid flag in pkg-config --cflags: -Xpreprocessor
这是我的规格:
macOS Mojave Version 10.14.3
vips Version 8.7.4
go Version 1.11.5 darwin/amd64
我读到一些添加 CGOALLOWEDFLAGS 的问题我也试过了,但没有成功。
CFLAGS
是给 C 编译器的额外标志。 (常用于make,见:https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html)
gopkg.in/h2non/bimg.v1/vips.go uses pkg-config
to generate the extra flags. It has -Xpreprocessor
标志,CGo 不允许(在撰写本文时默认情况下)。
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/)
要允许-Xpreprocessor
,可以设置CGO_CFLAGS_ALLOW=-Xpreprocessor
。
例如:
CGO_CFLAGS_ALLOW=-Xpreprocessor go vet ./...
我正在尝试 run/build 使用 vips 的 GoLang 包。当我尝试编译程序时出现此错误:
go build gopkg.in/h2non/bimg.v1: invalid flag in pkg-config --cflags: -Xpreprocessor
这是我的规格:
macOS Mojave Version 10.14.3
vips Version 8.7.4
go Version 1.11.5 darwin/amd64
我读到一些添加 CGOALLOWEDFLAGS 的问题我也试过了,但没有成功。
CFLAGS
是给 C 编译器的额外标志。 (常用于make,见:https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html)
gopkg.in/h2non/bimg.v1/vips.go uses pkg-config
to generate the extra flags. It has -Xpreprocessor
标志,CGo 不允许(在撰写本文时默认情况下)。
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/)
要允许-Xpreprocessor
,可以设置CGO_CFLAGS_ALLOW=-Xpreprocessor
。
例如:
CGO_CFLAGS_ALLOW=-Xpreprocessor go vet ./...