英文:
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
英文:
Compiler flags need to be specified before the list of input files, e.g.:
8g -o test1.8 test1.go
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论