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