drn34916 2017-07-14 15:56
浏览 344
已采纳

寻找有关如何在Golang中创建dll / so / dylib的基本示例/资源

I am looking to convert part of an app I have written in golang to a dll/dylib/so and make calls to it from my core golang app.

Does anyone know of any good resources or guides on how to do this as my searches are not turning up a great deal of info (much of what I'm finding are old requests for the feature which i understand is now included)

Please note: I have seen documentation on how to do the actual build, it is more around how to organise the app and expose methods that I am missing

I would also be interested in pros/cons of this approach if anyone has any experience doing something similar

  • 写回答

1条回答 默认 最新

  • dongyata3336 2017-07-14 18:54
    关注

    The c-shared buildmode is currently only supported on Linux.

    As seen here, Building a dll with Go 1.7, you may be able to build a DLL or shared lib using gcc, but it's not supported directly by the Go toolchain.

    However, if you're looking to create a "plugin" architecture, you don't want to create a C shared library, in which each instance creates a new Go runtime. There is already a plugin package which is intended for that purpose.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?