views:

210

answers:

1

Can i use shared objects with Go (Google) programming language?

+4  A: 

According to the Go FAQ, you can call into C libraries using a "foreign function interface":

Do Go programs link with C/C++ programs?

There are two Go compiler implementations, 6g and friends, generically called gc, and gccgo. Gc uses a different calling convention and linker and can therefore only be linked with C programs using the same convention. There is such a C compiler but no C++ compiler. Gccgo is a GCC front-end that can, with care, be linked with GCC-compiled C or C++ programs. However, because Go is garbage-collected it will be unwise to do so, at least naively.

There is a “foreign function interface” to allow safe calling of C-written libraries from Go code. We expect to use SWIG to extend this capability to C++ libraries. There is no safe way to call Go code from C or C++ yet.

To answer your earlier question about Windows DLL's: no, as there is currently not a windows implementation of Go. For more information, read can-go-compiler-be-installed-on-windows

Justin Ethier
I see that he tagged his question with "dll", but shared objects aren't exclusive to Windows, correct?
Joe Holloway
Agreed, but the original question was about DLL's. Just updated my answer...
Justin Ethier
first i writen "dll" then corrected to "shared objects"
SomeUser
Actually, you can call Windows DLL functions and there is a partial Windows implementation of Go. It's just not well documented yet.
Evan Shaw
Cool... Do you have a link or any more info?
Justin Ethier
@Justin There was a recent mailing list thread about it: http://groups.google.com/group/golang-nuts/browse_thread/thread/6c3a256bacfffe0e
Evan Shaw