【发布时间】:2014-11-16 08:58:04
【问题描述】:
这是我遇到过的最奇怪的问题。我在 Windows 2008 R2 虚拟机上设置了 Go 开发环境。我什至不重新启动它,也不运行 Windows 更新。
今天我才意识到我不能再运行 Go 程序了。我可以使用“go test”成功构建和运行单元测试。但是,运行任何已编译的 Go 程序(甚至是 hello world)会导致出现标题为“不支持的 16 位应用程序”的弹出窗口。错误信息如下:
此文件的版本与 Windows 的版本不兼容 你在跑。检查计算机的系统信息以查看 无论您需要 x86(32 位)还是 x64(64 位)版本的 程序,然后联系软件发行商。
无论我使用什么版本的 Go (x86/x64),结果都是一样的。另请注意,我没有使用任何 IDE。我从命令行调用 go.exe 来构建/测试。
我无法理解这一点,因为运行“go test”效果很好。
有什么想法吗?
编辑:
这是我构建和运行程序时的控制台输出:
有趣的是,dumpbin 表明可执行文件确实有问题
C:\Program Files (x86)\Microsoft Visual Studio 11.0>dumpbin /headers
C:\Projects \GoPlayground\src\playground\playground.exe Microsoft (R)
COFF/PE Dumper Version 11.00.51106.1 Copyright (C) Microsoft
Corporation. All rights reserved.
Dump of file C:\Projects\GoPlayground\src\playground\playground.exe
File Type: LIBRARY
C:\Projects\GoPlayground\src\playground\playground.exe : warning
LNK4003: invali d library format; library ignored
C:\Projects\GoPlayground\src\playground\playground.exe : warning
LNK4048: Invali d format file; ignored
Summary
C:\Program Files (x86)\Microsoft Visual Studio 11.0>
这是完整的源代码:
package playground
import "fmt"
import "playground/another"
func main() {
fmt.Println("Hello world!")
fmt.Println(another.Foobar(2))
}
-------------------
package another
func Foobar(i int) int {
return i + 1
}
EDIT2:
我已经重新安装了两次 Go,但没有任何效果。
【问题讨论】:
-
向我们展示您的工作,例如用一个简单的 hello world 显示你运行了哪些命令,你编译的文件在哪里以及任何其他感兴趣的东西,例如 `go -version 的输出
-
好的,我刚刚添加了更多信息。
-
如果重启系统,问题还会继续吗?
-
是的,确实如此。我认为 dumpbin 的输出确实有问题。我只是不知道如何调试构建过程。
标签: go