macos - 从 go 构建 vips 库的问题

标签 macos go vips

我正在尝试运行/构建一个使用 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/

相关文章:

macos - CGPathRef 到一组 CGRects

macos - Mac 窗口图标化按钮的 Hook

macos - 如何在 Mac OS X 上拍摄忽略应用程序窗口的区域的屏幕截图

linux - 如何将 ImageMagick 的 unsharpMask 设置转换为 VIPS 的 vips_sharpen() 设置

objective-c - 如何区分不同的NSTrackingAreas

google-app-engine - 在测试期间控制最终的 AppEngine 数据存储一致性

pointers - Go Programming - 使用指针绕过访问权限

go - 在 Go 中可以用什么来代替类型名称的映射字面量?

python - 从分块的 TIFF 中提取分块并存储在 numpy 数组中

python - pyvips 图像合成未按预期工作