packagemain.tech

packagemain.tech

Statically and Dynamically Linked Go Binaries

Examining the Go binaries and linkers.

Alex Pliutau's avatar
Alex Pliutau
Sep 09, 2024
∙ Paid

Overview

One of the biggest strengths of Go is its compiler, which abstracts many things for a programmer and lets you compile your program easily for almost any platform and architecture.

And though it seems easy, there are some nuances to it and multiple ways of compiling the same program which results in the different executable.

In this article, we’ll explore statically and dynamically linked executables, internal and external linkers, and examine binaries using tools like file, ld, ldd, etc.

What is Static and Dynamic linking?

Static linking is the practice of copying all the libraries your program needs directly into the final executable file image.

And Go loves and wants that whenever it’s possible, since it is more portable, as it doesn’t require the presence of the library on the host system where it runs. So your binary can run on any system no matter which distro/version, and not depending on any system libraries.

Dynamic linking on the other hand is when external or shared libraries are copied into the executable file by name during the run time.

And it has its own advantages too. For example the program can re-use popular libc libraries that are available on the host system and don’t re-implement them, you can also benefit from host updates without re-linking your program. It can also reduce the executable file size in many cases.

User's avatar

Continue reading this post for free, courtesy of Alex Pliutau.

Or purchase a paid subscription.
© 2026 Aliaksandr Pliutau · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture