I followed the following tutorials to create a static library.
http://tldp.org/HOWTO/Program-Library-HOWTO/static-libraries.html
http://www.adp-gmbh.ch/cpp/gcc/create_lib.html
http://www.cs.dartmouth.edu/~campbell/cs50/buildlib.html
I generated a static library in C using the ar tool. The library is from a different directory. I am generating the library properly, and I'm using it to compile with my program as follows:
gcc -lpthreads main.c -o server -L thread-pool -lthreadpool
The library under the current directory is called thread-pool which contains libthreadpool.a.
According to the tutorials, I need to include my .h file as follows in main.c: #include "threadpool.h". GCC is throwing an error saying threadpool.h is not found. That is obvious since it's in a different directory.
When I include is as: #include threadpool/threadpool.h" it compiles but doesn't actually work. It still does not recognise the functions. I'm not sure why this is happening. I thought when compiling a static library, you do not need to actually send the .h file or any source as a matter of fact.
What is the issue here? How can I overcome this?
EDIT:
I know .h files are not the same as static libraries. I'm not sure why what I said above make it seem as if I'm confused between both.
Anyway, so when one uses a static library, does it mean we also need the .h file and include it into the source, and not just compile the program with the static library?