Advertisement

Linking a program statically?

Started by February 06, 2005 01:51 PM
2 comments, last by GameDev.net 19 years, 10 months ago
I'm trying to compile a program and link it statically (so it doesn't depend on any libraries at runtime). I'm fairly sure this is possible with GCC/G++, and the closest option I have found is the -static option. Is this the correct way to link a program statically? Thanks in advance!
- fyhuang [ site ]
Quote: Original post by fyhuang
Is this the correct way to link a program statically?


To the best of my knowledge, it is.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
Great, thanks!
- fyhuang [ site ]
To determine if it worked, use ldd filename on your program to see which dynamic libraries it links to. Another way to link statically is to skip the -llibname option and just provide the .a file of the library you want to link statically in the linking command, as if it were one of the .o files.

This topic is closed to new replies.

Advertisement