Is there a way to build a dll against Go v1.7 under Windows ?
I tried a classic
go build -buildmode=shared main.go
-buildmode=shared not supported on windows/amd64
Ok, I’ve got my answer. For those who are interested :
As of Go 1.10, -buildmode=c-shared is now supported on Windows.
So now compiling to DLL is a one-liner:
go build -o helloworld.dll -buildmode=c-shared
I believe the headers are only compatible with GCC. If you’re only exposing C-types, this should not be a big issue. I was able to get LoadLibrary to work in Visual Studio without the header.
Answered By – Andrew Dolder
Answer Checked By – Marilyn (GoLangFix Volunteer)