Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
runtime/cgo: How to integrate go (via cgo) with MSVC2013 project? #15239
changed the title
x/mobile: How to integrate go (via cgo) with MSVC2003 project?
Apr 11, 2016
I am not really an expert here, but ...
Correct me if I am wrong. You want to build your Go code as DLL and use it with one of your programs.
But Go cannot create DLLs yet (see issue #11058 for details). And the plan proposed on issue #11058 is still not clear. And the plan is based on using mingw - mingw runtime might not work with your program. And I hope you've heard about downsides of using cgo - http://dave.cheney.net/2016/01/18/cgo-is-not-go - I can add more.
Perhaps you reconsider using standalone Go built executable. You can run it as a Windows service, if that helps any.
The thought is that while cgo/go cannot build dlls, a static library should be linkable INTO one. The only limitation (to my knowledge) is getting a compatible set of object code in that go c-archive. Once you have that, it's fairly trivial to link it into a dll.
Personally, I'd like to see our architecture be more akin to chrome where there is a main process which essentially becomes an launch controller for slave processes (where this standalone go exe would live), but it has been a nonstarter for given architectural constraints. Many in the org want to use Go as a common, first-class language here. I'm looking to take that momentum into some new products/tech spaces.
To do that I just need a solution for this last issue :-/
I'd be good not using cgo at all, but the sqlite3 driver in go is amalgamated c. If only there was a pure go sql impl.
If you know what to do, why don't you try and build what you want.
If you did try to build something, and are having problems, then you need to provide more details about what you did and what worked or not worked.
In my pre Go life I used sqlite3.dll to access sqlite functionality. I am certain it can be done with pure Go today. This is obviously "windows only" solution. And you would have to copy sqlite3.dll together with your Go executable everywhere.