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)
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)
You should
#include "libstatic.h"
, i.e. use the appropriate header file in your code (that's why your code doesn't compile) and include the path to yourlibstatic.a
in the linker options as one of your input libraries.This webpage has some examples on linking to a static library, e.g.
or
To link purely statically, use
-static
I had to set the library path in my makefile. For this case you could use: