Re:Golang at CloudFlare
by jkn on Tuesday July 03, 2012 @03:43PM
(#4195825)
Static linking is not easily available with C/C++ in the general case. Some libraries support it, some important ones like Glibc and GTK+ do not.
[ Parent
| on HN ]
The only reason this is not an issue with Go is that the language is too young and the reference compiler only supports static linking fot the time being.
The moment the compiler starts supporting dynamic linking the same will happen to Go.
Re:Golang at CloudFlare
by koenigdavidmj on Tuesday July 03, 2012 @04:55PM
(#4196151)
The Plan 9 people (basically the same group as the Go people) have some philosophical problems with dynamic linking. Read http://harmful.cat-v.org/software/dynamic-linking/ for their arguments.
Static linking of Go code is a conscious design decision, not some artifact of toolchain immaturity. It will never change.
You can make use of dynamic linking with gccgo, as far as I am aware.
Re:Golang at CloudFlare
by reddit_clone on Tuesday July 03, 2012 @05:22PM
(#4196251)
On a related note, using Go can one develop DLLs that can be dynamically consumed from other applications?
Or you can only produce statically linked exe's?
Only exes at the time being. Go is the main loop and needs to have control of the execution flow for concurrency.
If you think of it, DLLs are a bit like separate programs that you communicate with trough the C call stack instead of another structured protocol. In Go you would spawn different processes and use something like protobuf to exchange messages.
Huh? Perhaps you mean Glib? Static linking works just fine with glibc:
[me@host: tmp]% cat > hello.c
#include <stdio.h>
int main(void) { printf("hello world\n"); return 0; }
[me@host: tmp]% gcc -o hello -Wall hello.c -static
[me@host: tmp]% file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, not stripped
[me@host: tmp]% ldd hello
not a dynamic executable
[me@host: tmp]% ./hello
hello worldI largely agree with you, but for what it's worth, that doesn't "just work": there are places in glibc that use dlopen to pull in modular code; one example is the DNS resolver.
Re:Golang at CloudFlare
by tedunangst on Tuesday July 03, 2012 @08:34PM
(#4197000)
As mentioned, if you try that it works less than 100%. Trying to run a 32-bit program on a 64-bit host will fail in weird ways unless some of the expected bonus libraries are available.
Re:Golang at CloudFlare
by gillianseed on Tuesday July 03, 2012 @07:29PM
(#4196807)
Although I've never tried it myself I've read that gtk supports static linking, iirc you have to build gtk with --disable-modules.
Also, Go has gtk bindings, how does that work?
Ah you're right, it seems you can get a static build by recompiling GTK+ and its dependencies with the appropriate flags and some extra manipulation... See http://wiki.inkscape.org/wiki/index.php/CompilingStatic for an outdated example. I don't know if that would work on Windows, it used to be not supported: http://readlist.com/lists/lists.sourceforge.net/mingw-users/...
Re:Golang at CloudFlare
by tedunangst on Tuesday July 03, 2012 @08:31PM
(#4196990)
Go can dynanmically load C libraries I believe, but there is no support for native shared go code.
That is correct.