views:

492

answers:

2

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)

+1  A: 

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 your libstatic.a in the linker options as one of your input libraries.

This webpage has some examples on linking to a static library, e.g.

gcc -I. -o jvct jvct.c libjvc.a
Jacob
thank you. finally i got it done on codeblocks and I figured out that #include .h file not necessary the same name as the .a file.
tsubasa
+5  A: 
cc -o yourprog yourprog.c -lstatic

or

cc -o yourprog yourprog.c libstatic.a
dajobe
i tried the 2nd one and it works. thanks. i also could be able to configure for code::blocks to work too. :-)
tsubasa