Skip to content

Instantly share code, notes, and snippets.

@grantpullen
Last active March 7, 2019 08:33
Show Gist options
  • Save grantpullen/d91522b8f74a4282a5d2faf4ed661fe2 to your computer and use it in GitHub Desktop.
Save grantpullen/d91522b8f74a4282a5d2faf4ed661fe2 to your computer and use it in GitHub Desktop.
How to static compile c

Static Compile

Compile flags

Add the following -static -static-libgcc -static-libstdc++

Verify if executable is statically compiled

  1. Verify there is really no dynamic linkage ldd executable

  2. Verify there are no unresolved symbols nm executable | grep " U " The list should be empty or should contain only some special kernel-space symbols like U __tls_get_addr

  3. Run executable

source: https://stackoverflow.com/questions/3283021/compile-a-standalone-static-executable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment