我正在尝试使用go-qml或gotk 3来构建一个可以在OSX下运行的非常简单的桌面应用程序。但是,当我尝试使用go get
安装任何一个库时,它将尝试为i386构建,并跳过针对x86_64构建的库。我可以尝试获得这些库的32位版本,但我更喜欢为64位构建。我该如何指导你去做呢?
后面跟着错误的警告看起来是这样的:
go get gopkg.in/qml.v1
# gopkg.in/qml.v1
ld: warning: ld: warning: ld: warning: ignoring file /usr/local/Cellar/qt5/5.3.2/lib/QtWidgets.framework/QtWidgets, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/Cellar/qt5/5.3.2/lib/QtWidgets.framework/QtWidgetsignoring file /usr/local/Cellar/qt5/5.3.2/lib/QtGui.framework/QtGui, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/Cellar/qt5/5.3.2/lib/QtGui.framework/QtGuiignoring file /usr/local/Cellar/qt5/5.3.2/lib/QtQuick.framework/QtQuick, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/Cellar/qt5/5.3.2/lib/QtQuick.framework/QtQuick
2条答案
按热度按时间gzszwxb41#
将环境变量
GOARCH
设置为值amd64
。这将指示go
命令为amd64
生成文件。GOARCH
的其他有效值包括386
、arm
、arm64
等。idv4meu82#
仅供参考
Go编译器支持以下指令集:
(from:导言|从源代码安装Go| golang.org)
此外,您可以
go tool dist list
来检查要在您的机器中构建的可用架构。为macOS(Intel/ARM 64)构建一个静态二进制文件如下所示。在这种方式下,我假设
GOOS="darwin" GOARCH="arm64"
组合将用于M1
架构。要在ARM v6上编译Linux,例如RaspberryPi Zero W,组合如下。