Go二进制文件在哪些情况下是动态链接的?

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

In what cases are go binaries dynamically linked?

问题

Go编程语言的一个重要特性是它生成静态链接的二进制文件。然而,当我在$GOPATH/bin目录下运行ldd *命令时,我发现了几个动态可执行文件。是否有一套清晰的规则可以理解在什么情况下Go编译器会生成动态链接的二进制文件呢?

英文:

One important feature of the Go programming language is that it produces statically linked binaries. However, when I ran ldd * in my $GOPATH/bin, I found several dynamic executables. Is there a clear set of rules to understand under what circumstances does the go compiler produce dynamically linked binaries?

答案1

得分: 4

当使用cgo时,它是Go语言与C程序链接的方式,而C程序可以使用动态链接库。

英文:

When using cgo, which is how Go links to C programs, which can of course use dynamically-linked libraries.

答案2

得分: 1

Go 1.8引入了一种称为Go插件的东西,似乎使用了动态链接。

https://golang.org/pkg/plugin/

英文:

Go 1.8 has introduced something called Go Plugin which seems to be using dynamic linking.

https://golang.org/pkg/plugin/

huangapple
  • 本文由 发表于 2017年6月17日 23:40:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/44606374.html
匿名

发表评论

匿名网友

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

确定