How to create static binary which runs on every distro?

user1873947 picture user1873947 · Feb 12, 2013 · Viewed 34.3k times · Source

Some linux apps like supertuxkart or regnum online have static binaries, which after downloading just work without needing to install any shared library. On every distro. How can I make such an app?

Answer

thiton picture thiton · Feb 12, 2013

Ensure that all your resources are contained in the executable and link the executable statically:

gcc -o foo main.o -static -lbaz -lbar

However, this also has drawbacks. Look up dynamic linking.