Go代码可以在Windows上生成DLL吗?C++/C#可以调用Go语言代码吗?

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

Can Go code generate dll in windows or can C ++/C# call golang code?

问题

Go functions can be called by C++ or C# code on Windows. Go supports generating DLLs in Windows.

英文:

Can Go functions be called by C++ or C# code on windows? Does Go support generating dll in Windows?

答案1

得分: 9

不,Go代码是静态链接的。这是因为Go的运行时嵌入在每个可执行文件中,还有其他原因。


编辑:

显然可以通过很多间接方式实现,但在实践中远非可用。
有关更多信息,请参阅从C调用Go函数和链接的博客文章。

英文:

No, Go code is statically linked. The reason for this is Go's runtime, which is embeded in every executable, among other things.


Edit:

It is apparently possible with a lot of indirection, but far from usable in practice.
See Call go functions from C and the linked blog posts for more information.

huangapple
  • 本文由 发表于 2012年12月5日 17:54:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/13720425.html
匿名

发表评论

匿名网友

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

确定