Do you know projects that are compiles as shared libraries?

agolangf · 2017-09-29 06:01:23 · 522 次点击    
这是一个分享于 2017-09-29 06:01:23 的资源,其中的信息可能已经有所发展或是发生改变。

I’m considering Go for a new project that is supposed to be usted by other languages. So, the solution seems to be to create a shared library (Linux only).

I know this can be done with cgo, but I would like to see a real project that uses the same model.

Does anyone knows about a project that is used as a shared library?


评论:

kostix:

the solution seems to be to create a shared library (Linux only). I know this can be done with cgo

This is not correct: the Go compiler supports a special "build mode" called "c-shared" which produces a shared library with C-style API. The cgo subsystem is not involved in this process (in the sense you don't use import "C" and stuff); you just supply the -buildmode=c-shared command-line option to the compiler — see this and this.

igknighted:

Working example test I did for something I was trying out recently. I did a c-archive instead of a shared library, but the principal is similar.

https://gist.github.com/protosam/edcc00cc309b5f4a163ece39c46d9e4a

tv64738:

That'll still need the Go runtime active, it won't behave like a C library. I would recommend against trying to embed Go in another language.


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

522 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传