How to link to a static library in C?

user188276 picture user188276 · Nov 10, 2009 · Viewed 95.8k times · Source

I use code::blocks to compile my static library. The output result is a libstatic.a file. Now, how do I link to my library to use functions that were compiled?

(I tried to use #include "libstatic.a" but my project doesn't compile)

Answer

dajobe picture dajobe · Nov 10, 2009
cc -o yourprog yourprog.c -lstatic

or

cc -o yourprog yourprog.c libstatic.a