Do you know projects that are compiles as shared libraries?

agolangf · · 409 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>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).</p> <p>I know this can be done with cgo, but I would like to see a real project that uses the same model. </p> <p>Does anyone knows about a project that is used as a shared library?</p> <hr/>**评论:**<br/><br/>kostix: <pre><blockquote> <p>the solution seems to be to create a shared library (Linux only). I know this can be done with cgo</p> </blockquote> <p>This is not correct: the Go compiler supports a special &#34;build mode&#34; called &#34;c-shared&#34; which produces a shared library with C-style API. The <code>cgo</code> subsystem is not involved in this process (in the sense you don&#39;t use <code>import &#34;C&#34;</code> and stuff); you just supply the <code>-buildmode=c-shared</code> command-line option to the compiler — see <a href="https://golang.org/doc/go1.5#link" rel="nofollow">this</a> and <a href="https://golang.org/doc/go1.6#compiler" rel="nofollow">this</a>. </p></pre>igknighted: <pre><p>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. </p> <p><a href="https://gist.github.com/protosam/edcc00cc309b5f4a163ece39c46d9e4a" rel="nofollow">https://gist.github.com/protosam/edcc00cc309b5f4a163ece39c46d9e4a</a></p></pre>tv64738: <pre><p>That&#39;ll still need the Go runtime active, it won&#39;t behave like a C library. I would recommend against trying to embed Go in another language.</p></pre>

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

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