How to get cgo to work on windows 64 bit?

agolangf · 2017-03-23 03:00:08 · 1026 次点击    
这是一个分享于 2017-03-23 03:00:08 的资源,其中的信息可能已经有所发展或是发生改变。

A library I wanted to use complained about gcc.exe not being in PATH.

https://golang.org/doc/install#requirements told me to install MinGW gcc. (By the way "A C compiler is required only if you plan to use cgo." is wrong. You don't need to plan to use it to end up having to use it.)

I installed Mingw from the official website and now the library install says

cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

I thought go was supposed to be easy and to just work?


评论:

SilentWeaponQuietWar:

Try this, I'm pretty sure I remember it working for me on windows when nothing else would

http://tdm-gcc.tdragon.net/

au_travail:

Thank you it worked. This should be linked on https://golang.org/doc/install#requirements

SilentWeaponQuietWar:

glad it helped. I can't tell you how many hours of frustration I went through before finding it mentioned in some obscure forum. I agree it should be at least cited somewhere. Everyone always links to mingw and I've never gotten it to work.

au_travail:

ok I am trying it

au_travail:

Lol now the https://sourceforge.net/projects/mingw-w64/ installer tells me "the file has been downloaded incorrectly!" and quits.

au_travail:

I thought I found a way to install 64-bit Windows gcc, but new errors...

>go get github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
/usr/lib/gcc/x86_64-pc-msys/6.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find
 -lmingwex
/usr/lib/gcc/x86_64-pc-msys/6.3.0/../../../../x86_64-pc-msys/bin/ld: cannot find
 -lmingw32
collect2: error: ld returned 1 exit status
The_Jare:

I recall installing MinGW-W64 GCC-6.3.0, x86_64-posix-seh from https://sourceforge.net/projects/mingw-w64/files/ and it seemed to work fine.

au_travail:

https://www.reddit.com/r/golang/comments/60xr8t/how_to_get_cgo_to_work_on_windows_64_bit/dfa4qr3/

The_Jare:

I meant the actual zip file for that version/options combo, not the online installer.

au_travail:

Ah ok.

cube2222:

This will be a pretty non-standard proposition, but why not use bash on ubuntu on windows?

The cgo stuff is much less cross-platform than the standard Go stuff and you're just going to be causing a lot of pain to yourself.

au_travail:

How am I causing pain to myself?

cube2222:

By using cgo with windows -> in my opionion.

EDIT: With bash on ubuntu on windows you have a fully compatible linux environment.

au_travail:

By using cgo with windows -> in my opionion.

I had to because I have Windows and the library I have to use asks for cgo.

bakunin:

As /u/cube2222 says you can enable bash on ubuntu on windows (now there's a mouthful) if you're on Windows 10:

https://msdn.microsoft.com/en-us/commandline/wsl/install_guide


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1026 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传