可以将Go包编译成.so或.a文件吗?

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

Is it possible to make go packages a .so or .a file?

问题

最近我花了一些时间学习cgo以及如何在Go语言中编写C代码。使用#cgo指令加载.so文件似乎非常简单。然而,是否有办法以相反的方式进行操作呢?也就是说,我们是否可以将一个Go包构建成.so或.a文件,以便可以直接在C/C++项目中使用?

英文:

Recently I have spent some time on cgo and how to write C codes in go. It seems very easy to load a .so file by using #cgo directives. However, are there any ways that we can do this in a opposite way? That is, can we build a go package to a .so or .a file so that it can be used by c/c++ projects directly?

答案1

得分: 3

答案是目前还不能将Go代码动态加载到C代码中。

虽然有一些相关的活动正在进行,但目前还没有准备好。

请参阅邮件列表上的讨论

英文:

The answer is Go code can't be dynamically loaded into C code yet.

There is some activity on making this possible, but it isn't ready now.

See the discussion at on the mailing list.

huangapple
  • 本文由 发表于 2013年11月10日 11:51:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/19886074.html
匿名

发表评论

匿名网友

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

确定