Search code examples
cbuildcompilationstatic-libraries

How to link to a static library in C?


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)


Solution

  • cc -o yourprog yourprog.c -lstatic
    

    or

    cc -o yourprog yourprog.c libstatic.a