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 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类