So I want to use the redemption COM library in go.
I could already successfully use it by registering it first and then using Go-OLE to call functions.
But ideally I want to use it without having to register it first.
When I searched on linking a dll in go I have found many answers saying to use cgo, but I could not find a tutorial, describing on how to use cgo.
After reading the cgo documentation, and this answer about cross compiling (I am cross compiling from Ubuntu linux amd64 to windows amd64) I figured that I could probably use the dll by setting my environment variables to
GOOS=windows;GOARCH=amd64;CGO_ENABLED=1;CXX=x86_64-w64-mingw32-g++;CC=x86_64-w64-mingw32-gcc
And writing a go file like this
package main
//#cgo windows LDFLAGS: -L/go/src/tryingout/Redemption64.dll
import "C"
import "fmt"
func main() {
session := C.Redemption.RDOSession
fmt.Println(session)
}
Unfortunately this did not work, I received the could not determine kind of name for C.Redemption
error at compilation. I have looked it up and it means that Redemption does not exist. But I do know that it should be called like this since 1)It should be according to the documentation of redemption and 2) It worked before with go-ole
There is also a loader class written in C#, C++ and other languages by the redemption developer but I could not use that either because it was somehow always interpreted as C instead of C++ and thus resulted in errors. I tried this solution and added -lstdc++
to my LDFLAGS, but it made no difference.
So my question is how do I load and use this COM library or where can I find a tutorial/example code that explains it?