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