为什么在Go语言命令行中,”8g foo.go -o foo.8″对我不起作用?

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

Why doesn't "8g foo.go -o foo.8" work for me in go language command line?

问题

我正在尝试编译一个hello-world应用程序:

8g test1.go -o test1.8

错误:

open -o: 没有这个文件或目录

讽刺的是,当我省略-o时,这个命令可以正常工作:

8g test1.go

如何在go命令行编译器8g中指定一个对象文件名?

(8g版本 release.r60 9481)

英文:

I'm trying to compile a hello-world app:

8g test1.go -o test1.8

Error:

open -o: No such file or directory

Irony here being that this works fine when I leave off -o:

8g test1.go

How do you specify an object filename to go command line compiler 8g?

(8g version release.r60 9481)

答案1

得分: 2

当不带参数运行8g时,它会打印类似以下内容:

gc: usage: 8g [flags] file.go...
flags:
  ...
  -m 打印优化决策
  -o file 指定输出文件
  -p 假定的导入路径
  ...

注意,[flags]位于file.go之前。在传递参数时需要遵守这个顺序。这与gcc不同,gcc可以接受任意顺序的选项和文件。

英文:

When 8g is run without arguments, it prints something like this:

gc: usage: 8g [flags] file.go...
flags:
  ...
  -m print optimization decisions
  -o file specify output file
  -p assumed import path for this code
  ...

Notice that [flags] are positioned in front of file.go. This ordering needs to be respected when passing arguments. This is unlike gcc which accepts options and files in any order.

答案2

得分: 1

基于文档

http://golangtutorials.blogspot.com/2011/05/checking-we-have-go-setup-right.html

https://stackoverflow.com/questions/4503972/multiline-command-go-in-scite

http://sourcetree.wordpress.com/tag/go/

你可以尝试

>8g test1.go 
>8l -o test1.8
>./8.out
英文:

based on documentation

http://golangtutorials.blogspot.com/2011/05/checking-we-have-go-setup-right.html and

https://stackoverflow.com/questions/4503972/multiline-command-go-in-scite and

http://sourcetree.wordpress.com/tag/go/

You can try

>8g test1.go 
>8l -o test1.8
>./8.out

答案3

得分: 1

编译器标志需要在输入文件列表之前指定,例如:

8g -o test1.8 test1.go

请参阅 http://golang.org/cmd/gc/

英文:

Compiler flags need to be specified before the list of input files, e.g.:

8g -o test1.8 test1.go

See http://golang.org/cmd/gc/

huangapple
  • 本文由 发表于 2012年3月30日 22:12:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/9944652.html
匿名

发表评论

匿名网友

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

确定