gccgo在Precise上

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

gccgo on Precise

问题

尝试在Precise上使用gccgo进行链接时,我遇到了以下链接错误:

matt@matt-1005P:~/src/gopath/src/meme$ gccgo cmd/meme/main.go -o meme
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

有关此错误的报告,但没有明确的解决方案。我该如何修复它?

gccgo (Ubuntu/Linaro 4.7.0-0ubuntu4) 4.7.0

Linux matt-1005P 3.2.0-24-generic-pae #38-Ubuntu SMP Tue May 1 16:40:26 UTC 2012 i686 i686 i386 GNU/Linux

英文:

When trying to link with gccgo on Precise, I get this linking error:

matt@matt-1005P:~/src/gopath/src/meme$ gccgo cmd/meme/main.go -o meme
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

There are reports of this error, but no clean solutions. How do I fix it?

>gccgo (Ubuntu/Linaro 4.7.0-0ubuntu4) 4.7.0
>
>Linux matt-1005P 3.2.0-24-generic-pae #38-Ubuntu SMP Tue May 1 16:40:26 UTC 2012 i686 i686 i386 GNU/Linux

答案1

得分: 10

这是最近在golang-nuts组中提出的问题:使用打包的二进制文件编译gccgo

这是Ubuntu中已知的问题(Bug #966570)。为了解决这个问题,你可以通过在gccgoflags中指定-static-libgcc来链接静态libgcc。例如:

go build -compiler gccgo -gccgoflags '-static-libgcc';
英文:

This was recently brought up on the golang-nuts group: compiling with gccgo from packaged binaries.

It's a known issue in Ubuntu (Bug #966570). To work around it, you can link with the static libgcc by specifying -static-libgcc in the gccgoflags. i.e.

go build -compiler gccgo -gccgoflags '-static-libgcc'

答案2

得分: 1

根据我所了解的情况,这是因为gccgo基于GCC 4.7,而Precise默认使用GCC 4.6。由于某种原因,库路径不正确,或者包不完整,因为缺少libgcc_s

我使用find / -name 'libgcc_s*'找到了可能的库,并像这样传递了库路径:

go install -compiler=gccgo -gccgoflags -L/usr/lib/gcc/i686-linux-gnu/4.6 meme/cmd/meme

请注意,这是链接到4.6的libgcc_s,但似乎仍然可以工作。

英文:

From what I can tell, it's because gccgo is based on GCC 4.7, but Precise uses GCC 4.6 by default. For whatever reason, the library paths are incorrect, or the package is incomplete because it's missing libgcc_s.

I located possible libraries with find / -name 'libgcc_s*' and passed the library path like so:

go install -compiler=gccgo -gccgoflags -L/usr/lib/gcc/i686-linux-gnu/4.6 meme/cmd/meme

Note that this is linking against 4.6's libgcc_s, but seems to work anyway.

答案3

得分: 0

/usr/bin/ld: 找不到 -lgcc_s (找不到 lgcc_s.so)

gccgo -v (我们的 gcc 版本为 4.7.0 (Ubuntu/Linaro 4.7.0-1ubuntu5) )

locate libgcc_s.so.1

/lib/i386-linux-gnu/libgcc_s.so.1

ln -sf /lib/i386-linux-gnu/libgcc_s.so.1 /usr/lib/gcc/i686-linux-gnu/4.7.0/libgcc_s.so

OK

英文:
/usr/bin/ld: cannot find -lgcc_s (cannot find lgcc_s.so)

gccgo -v (we gcc version 4.7.0 (Ubuntu/Linaro 4.7.0-1ubuntu5) )

locate libgcc_s.so.1 

/lib/i386-linux-gnu/libgcc_s.so.1

ln -sf /lib/i386-linux-gnu/libgcc_s.so.1 /usr/lib/gcc/i686-linux-gnu/4.7.0/libgcc_s.so 

OK

huangapple
  • 本文由 发表于 2012年5月14日 14:01:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/10578125.html
匿名

发表评论

匿名网友

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

确定