Hi!
Unfortunately you forgot to use the "reply to all" or "reply to list"
action so the message has only been sent to me, not to the list.
Please re-send/re-post correctly.
> after one day's study, I can use CGO with DLL on Windows now, it seems that
> the CGO's code is same for static or dynmatic libs.
>
> but I still don't know the right way to tell ld where is the DLL.
>
> now I need to put the DLL into this MINGW64's lib path:
> C:\Bin\mingw-w64\x86_64-7.1.0-win32-seh-rt_v5-rev0\mingw64\x86_64-w64-mingw32\lib
Please see the help on the cmd/cgo "package" (running `go help cmd/cgo`
is one way to get this help, or navigate to [1].
Basically you use something like
// #cgo LDFLAGS=-Lpath/to/the/dll -ldllname
in your cgo comment block to make the contents of that variable passed
to the linker.
> for syscall's float problem, I found this:
>
> I'm wondering if we can link a go code via cgo with a dll created with
> mingw-gcc?
>
> It's possible. Add the path to the DLL to the cgo LDFLAGS, and use cgo to
>
> call exported function from DLL as usual.
>
> To call integer functions from DLL, you can also use the syscall package
> (search for DLL
>
> in godoc), but there are some constrains in calling functions using the
> syscall package
>
> (you can't pass floating point arguments, and the stack size is limited to
> 64K if it's a pure
>
> Go program), so the recommended way to use a windows DLL (no matter how
> it's created,
>
> MSVC or mingw) is to use cgo.
I was able to google for one of the exact phrase out of this citation,
and found out that most probably you were referring to this post on
golang-nuts [2]. Next time, please do this yourself so we have a proper
context of the citation (which can be studied and used for future
reference).
I'm not sure what to say about that: minux is definitely a knowledgeable
person; I had extensive experience calling Windows DLLs via the syscall
package but I never had a chance of calling functions which would
require passing double/float arguments from Go.
I wonder whether Alex Brainman maybe has something to say on these
matters.
1.
https://golang.org/pkg/cmd/cgo/
2.
https://groups.google.com/d/msg/golang-nuts/EdqqBX1EolI/SQ1HXhfoaAsJ