Export functions from DLL
Hi, i'm approaching the world of GoLang, but I can't interface with the DLL due to the functions not externally exposed. Is it possible to expose the connection and reading functions variables from the WASimClient?
Hello,
Assuming you mean the DLL from the "lib/dynamic" folder of the distro, it is C++, the exported function names are mangled. Is that the issue?
I just ran dumpbin /exports WASimClient.dll to confirm. It's all in there.
To create a DLL with exported C functions we'd need a wrapper for the C++ client.
I don't know anything about GoLang... would it be easier to interface with the managed (.NET) version instead?
Cheers, -Max
That's right by trying with the WASimCommander.WASimClient.dll as in the example with python, I didn't find any references, so I checked the WASimClient.dll which actually had the functions with mangled names.
Unfortunately I also don't know much about GoLang, but from what I've searched there are no libraries like clr for python, so accessing the dll is more complex.
Thanks for the answer, I'm still playing with the code so nothing serious! I'm not an expert so probably mine was also a stupid question! :D
Thanks! Marco
A quick Google/StackOverflow search on interfacing Go with C++ looks promising (SWIG maybe?), but it's a bit of a swamp trying to figure out versions and what's old news and what's new (eg. https://stackoverflow.com/questions/1713214/how-to-use-c-in-go). Some later answers seem to suggest you can embed C++ code into Go (with cgo alone and supported compilers) and then call them from Go code... I was thinking maybe some simple wrapper functions to call the WASimClient methods. Not sure in either of those scenarios if you can still link to the DLL, or build it statically, or even just even include/build all the WASimClient code with your project.
I found a couple projects for using .NET assemblies/DLLs in Go (with WASimCommander.WASimClient.dll)... not clear if it's any simpler to interface with that really, nor how current these projects are. https://github.com/matiasinsaurralde/go-dotnet and https://github.com/ropnop/go-clr
I'm open to writing/having a C-style DLL wrapper for the WASimClient, which may ultimately be more useful for other bindings as well (eg. "native" Python). But if there's a way to use the current C++ code/lib, I'd say go for that.
I'll leave this issue open, please update with what you think the most efficient way forward may be!
Thanks, -Max