Building a dll with Go 1.7

前端 未结 3 1815
生来不讨喜
生来不讨喜 2020-12-07 23:39

Is there a way to build a dll against Go v1.7 under Windows ?

I tried a classic

go build -buildmode=shared main.go

but get

3条回答
  •  没有蜡笔的小新
    2020-12-08 00:22

    go build -buildmode=c-archive github.com/user/ExportHello
    

    ====> will build ExportHello.a, ExportHello.h

    Take the functions built in ExportHello.a and re-export in Hello2.c

    gcc -shared -pthread -o Hello2.dll Hello2.c ExportHello.a -lWinMM -lntdll -lWS2_32
    

    ====> will generate Hello2.dll

提交回复
热议问题