c - 去 1.5+ : Error - imports runtime: C source files not allowed when not using cgo or SWIG

标签 c go build compilation

我的程序与 go 1.4.2 完美构建。安装 go 1.5 后,出现以下错误。

imports runtime: C source files not allowed when not using cgo or SWIG: atomic_amd64x.c defs.c float.c heapdump.c lfstack.c malloc.c mcache.c mcentral.c mem_linux.c mfixalloc.c mgc0.c mheap.c msize.c os_linux.c panic.c parfor.c proc.c runtime.c signal.c signal_amd64x.c signal_unix.c stack.c string.c sys_x86.c vdso_linux_amd64.c

错误与程序无关。即使是“Hello world”程序也会抛出同样的错误。

最佳答案

Remove Old 1.4.x go installation and then install go 1.5.

安装 go 1.5 后我遇到了同样的问题。问题是我在 1.4.2 的同一个地方安装了 go 1.5。 Go 1.5 不再使用 C,如果存在旧的 C 安装文件,它会抛出错误,如图所示。

如果您希望旧安装也存在,则将 1.5 安装到其他位置并将 GOROOT 设置为该位置。

希望对你有帮助。

编辑 1:对于 Linux 用户:

如果你下载了 go1.5*.tar.gz 那么你是这样做的:

tar -C /usr/local/ -xvf go1.5.linux-amd64.tar.gz

你的旧文件夹C文件没有被删除,所以正确的过程是:

首先:您应该删除旧的 go 文件夹。

sudo rm -rf /usr/local/go/

第二:然后运行

tar -C /usr/local/ -xvf go1.5.x.linux-amd64.tar.gz

关于c - 去 1.5+ : Error - imports runtime: C source files not allowed when not using cgo or SWIG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32115229/

相关文章:

go - 我如何判断我的 interface{} 是否是一个指针?

java - 是否可以使用maven读取SVN中的最后修订版本号?

macos - LibPNG + Boost::GIL: 找不到 png_infopp_NULL

linux - 在 Debian 或 Ubuntu 下自动获取构建依赖项的 Debian 方式是什么?

c++ - 外部错误 - undefined reference

c - 禁用适配器时 NdisFSendNetBufferLists 导致 BSoD

c - 为什么使用此 C 代码会出现段错误?

c - SIGALRM 中断系统调用

arrays - 使用解码到通用接口(interface)时如何验证 JSON?

go - 使用没有协议(protocol)定义的托管编写器