I am using Ubuntu Linux I have made a custom static library Mylib.a, I can include it to only those c files which are in the same directory as the static library.
I want to make it a general library so that I can include the library file to any c file I want irrespective of its location
To use a static library you have to include the header in the .c files that use the library and then link the library. If the name of the library is libstatic.a
then:
gcc -o yourprog yourprog.c -lstatic
If the library is not in the same directory use the -L option to specify the path:
gcc -o yourprog yourprog.c -L/path-to-lib -lstatic
(see also this post: How to link to a static library in C?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With