你如何让gccgo编译pig.go?

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

How do you make gccgo compile pig.go?

问题

在golang.org网站上有一个名为pig.go的文件:

http://golang.org/doc/codewalk/functions/
在一个标有doc/codewalk/pig.go的框中

使用gccgo版本(Ubuntu/Linaro 4.6.1-9ubuntu3)4.6.1编译它

gccgo pig.go
会出现一个关于找不到math/rand的错误信息

pig.go:9:11: error: import file ‘math/rand’ not found

英文:

There is a file pig.go on the golang.org website:

    http://golang.org/doc/codewalk/functions/ 
    in a box labeled doc/codewalk/pig.go

Compiling it with gccgo version (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

    gccgo pig.go 

gives an error message about not finding math/rand

    pig.go:9:11: error: import file ‘math/rand’ not found

答案1

得分: 5

你的版本的gccgo实现了一种旧版本的语言。要编译Go 1代码,你需要gccgo 4.7.1或更高版本。

如果你不能或不想升级,你可能只需将导入从math/rand改为rand,然后它将能够在gccgo 4.6.1下编译。并非所有程序都能如此轻松地回溯,但这个程序恰好可以。

英文:

Your version of gccgo implements an old version of the language. To compile Go 1 code, you need gccgo 4.7.1 or later.

If you can't or don't want to upgrade, you could probably just change the import from math/rand to rand and it will compile with gccgo 4.6.1. Not all programs will be so easy to backport, but this one happens to be.

huangapple
  • 本文由 发表于 2012年7月21日 17:39:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/11591080.html
匿名

发表评论

匿名网友

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

确定