gpt4 book ai didi

macos - 从 go 构建 vips 库的问题

转载 作者:IT王子 更新时间:2023-10-29 01:43:50 25 4
gpt4 key购买 nike

我正在尝试运行/构建一个使用 vips 的 GoLang 包。当我尝试编译程序时出现此错误:go build gopkg.in/h2non/bimg.v1: 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使用 pkg-config 生成额外的标志。它有 -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 ./...

关于macos - 从 go 构建 vips 库的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54755571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com