dongsonglian7303 2019-07-19 23:50
浏览 86
已采纳

Windows DLL文件的正确的构建模式是什么?

These two steps:

gcc -c main.c
gcc -o a.exe main.o MyThing.dll

Work great to make windows exe that can call methods inside MyThing.dll. Note gcc main.c without the -c would give error like:

undefined reference to MyThing_method

But when trying to get this same system working in a Golang program using cgo I get same undefined reference errors like I did with gcc without the -c. I've read:

https://github.com/golang/go/wiki/WindowsDLLs

And would love to try and use syscall.NewLazyDLL but my issue is my foo.go file is calling C.SomeMethod() and inside that method it makes calls to the methods inside the DLL. So it seems I need a way to

go build -buildmode=c-share -o MyThing.dll

But I can't seem to get the right sequence. Am I right that if I can do this in the simple C program, there must be a way to do this from Golang?

  • 写回答

1条回答 默认 最新

  • dpyic24480 2019-07-21 22:00
    关注

    I ended up just getting rid of this extra c file and calling the methods I needed from Go like https://github.com/golang/go/wiki/WindowsDLLs explains. Works great.

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

报告相同问题?

悬赏问题

  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。