Shared libraries on windows (dll and xll)

463 views
Skip to first unread message

viktor...@gmail.com

unread,
Sep 16, 2015, 10:31:15 AM9/16/15
to golang-nuts
Hi,

I am in the process of writing an excel extension (xll - https://msdn.microsoft.com/EN-US/library/office/bb687850.aspx). This is a shared library / dll with some restrictions (such as x86, calling convention and need to export functions with particular names and signatures) (and also able to call back into excel through another shared library).

Now, I have been looking into trying to do this with golang, but am a bit uncertain if it will be possible at all. In particular the following are the things would to my understanding be needed:

 - Being able to build a (x86) shared library as a dll => This seems as if it is possible with gccgo but not with the standard compiler. (maybe)
 - Make the compiled library use the __stdcall convention, this seems to be the default for cgo on windows.
 - Making the built library being able to call into other shared libraries (dll's), this also seems possible for both cg and gccgo.

However, when reading I also find several posts/text which indicate that it may not be posible to achive what I want using golang today in particular relating to builds of type plugin). Does anyone have any experience in this, i.e. will it at all be possible or had I better just resort to C++ (which I ideally would prefer not to)? If so would my best bet be to try to use cgo or gccgo?

Thankful for any pointers

Viktor

Some additional links:
https://golang.org/doc/install/gccgo -> section on function names seems to indicate that function names get mangled when exported
https://golang.org/cmd/cgo/ -> Seems to support both calling into and from c, but not building as a shared library
https://groups.google.com/forum/#!searchin/golang-nuts/shared$20plugin/golang-nuts/0VCAR9H90yM/au0iCOYvQuQJ - states that build mode plugin is not implemented, but a c-shared which may or may not be sufficient

Aram Hăvărneanu

unread,
Sep 16, 2015, 10:40:08 AM9/16/15
to viktor...@gmail.com, golang-nuts
It is not currently possible with either gc or gccgo.

Gc just recently started getting support for running as a ELF shared
library, however there is no support for running as PE shared library
at all yet. It would be a lot of work to implement that support.

Gccgo currently can't produce Windows binaries at all.

--
Aram Hăvărneanu

viktor...@gmail.com

unread,
Sep 16, 2015, 10:53:36 AM9/16/15
to golang-nuts, viktor...@gmail.com
Right, ok, thanks.
Reply all
Reply to author
Forward
0 new messages