dp610807 2017-03-17 21:54
浏览 415

用gccgo构建Go-fork / exec没有这样的文件或目录

I am trying to run a simple helloworld.go on RHEL 6.8.

% cat helloworld.go 
package main
import "fmt"
func main() {
    fmt.Println("hello world")
}

The GC compiler works ok

%  go build -compiler gccgo helloworld.go 
go build command-line-arguments: : fork/exec : no such file or directory

For some reason, instead, I need to compile with gccgo, but could never get it to compile. Let alone to eventually compile it statically.

% go build -compiler gccgo -gccgoflags '-static' helloworld.go
go build command-line-arguments: : fork/exec : no such file or directory
% go build -compiler gccgo -gccgoflags '-static-libgo' helloworld.go
go build command-line-arguments: : fork/exec : no such file or directory


% go version 
go version go1.7 linux/amd64
% gcc --version
gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)

Insights on what the problem is would be appreciated?

  • 写回答

1条回答 默认 最新

  • dqy92287 2017-11-14 16:47
    关注

    You should install gccgo compiler first. On my Fedora 26 desktop, run dnf install gcc-go to install.

    $ which gccgo /usr/bin/gccgo go build --compiler gccgo -x WORK=/tmp/go-build848309745 mkdir -p $WORK/_/home/sam/sandbox/go/src/hello/_obj/ mkdir -p $WORK/_/home/sam/sandbox/go/src/hello/_obj/exe/ cd /home/sam/sandbox/go/src/hello /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-relative-import-path=_/home/sam/sandbox/go/src/hello -o $WORK/_/home/sam/sandbox/go/src/hello/_obj/_go_.o ./helloworld.go ar rc $WORK/_/home/sam/sandbox/go/src/libhello.a $WORK/_/home/sam/sandbox/go/src/hello/_obj/_go_.o cd . /usr/bin/gccgo -o $WORK/_/home/sam/sandbox/go/src/hello/_obj/exe/a.out $WORK/_/home/sam/sandbox/go/src/hello/_obj/_go_.o -Wl,-( -m64 -Wl,--whole-archive -Wl,--no-whole-archive -Wl,-) cp $WORK/_/home/sam/sandbox/go/src/hello/_obj/exe/a.out hello

    If you need to link static, package glibc-static and libgo-static are required to be installed too. After installed them, compile using gccgo and link statically by

    $ go build -compiler gccgo -x --gccgoflags "-static" WORK=/tmp/go-build815863722 mkdir -p $WORK/_/home/sam/sandbox/go/src/hello/_obj/ mkdir -p $WORK/_/home/sam/sandbox/go/src/hello/_obj/exe/ cd /home/sam/sandbox/go/src/hello /usr/bin/gccgo -I $WORK -c -g -m64 -fgo-relative-import-path=_/home/sam/sandbox/go/src/hello -o $WORK/_/home/sam/sandbox/go/src/hello/_obj/_go_.o -static ./helloworld.go ar rc $WORK/_/home/sam/sandbox/go/src/libhello.a $WORK/_/home/sam/sandbox/go/src/hello/_obj/_go_.o cd . /usr/bin/gccgo -o $WORK/_/home/sam/sandbox/go/src/hello/_obj/exe/a.out $WORK/_/home/sam/sandbox/go/src/hello/_obj/_go_.o -Wl,-( -m64 -Wl,--whole-archive -Wl,--no-whole-archive -Wl,-) -static cp $WORK/_/home/sam/sandbox/go/src/hello/_obj/exe/a.out hello

    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配