使用golang进行Mac交叉编译(或其他替代方法)

huangapple go评论74阅读模式
英文:

Mac cross compiling (or alternatives) with golang

问题

好的,我会为你翻译以下内容:

好的,我正在尝试在我的Mac上编译我的Awesomium的Go 包装器(在Linux上一切正常)。我的问题是,当我尝试编译时,我得到以下错误信息:
>ld: 警告: 忽略文件 /Library/Frameworks//Awesomium.framework/Awesomium,该文件是为 i386 构建的,而链接的架构是 x86_64:/Library/Frameworks//Awesomium.framework/Awesomium
未定义符号,适用于架构 x86_64:

好的。但这引发了一些问题。首先,我没有选择下载适用于Mac的x86_64版本,只有“Mac版本”,没有指定架构。其次,我检查了一些其他库,似乎没有任何库是以x86_64构建的。
现在我想也许我可以为OSX创建一个i386版本,但似乎交叉编译cgo非常困难,有人说是不可能的。

那么我的选择是什么?

英文:

Ok so I'm trying to compile my Awesomium go wrapper on my mac (everything works fine on linux). My problem is, when I try to compile I get
>ld: warning: ignoring file /Library/Frameworks//Awesomium.framework/Awesomium, file was built for i386 which is not the architecture being linked (x86_64): /Library/Frameworks//Awesomium.framework/Awesomium
Undefined symbols for architecture x86_64:

Fine. But that raises a few questions. First, I didn't have the option to download a x86_64 version for Mac, it was "the mac version" no architecture. Second, I checked a few other libraries and it seems like nothing is built x86_64.
Now I thought maybe I could make a i386 version just for osx but it seems it's extremely difficult, some say impossible, to cross compile cgo.

What are my options?

答案1

得分: 1

我不确定你是否会在通用二进制文件中遇到其他问题,但构建一个i386的Go工具链相当容易。

你可以参考这个链接:http://golang.org/doc/install/source

然后设置GOHOSTARCHGOARCH环境变量,例如:

GOHOSTARCH=386 GOARCH=386 ./all.bash
英文:

I'm not sure if you're going to run into any other problems with the universal binary, but building an i386 go toolchain is fairly easy.

http://golang.org/doc/install/source

You can then set the GOHOSTARCH and GOARCH environment variables, e.g.

GOHOSTARCH=386 GOARCH=386 ./all.bash

huangapple
  • 本文由 发表于 2015年2月20日 02:16:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/28613885.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定