Reputation: 57
I have made makefile which is creating shared library of two C code files (I used gcc). Makefile is also creating runnable main C file. Now I need to know how to tell main C file to use my shared library - because I need to use functions which are already contained in code files in shared library. Thanks for the help.
Upvotes: 2
Views: 195
Reputation: 134326
#include
the header file containing the declaration of the function(s) you want to use in your main file.
link with your shared library using -L/path/to/libraries abc.c -l<yourLIb>
. [Assuming your libary name is lib<yourLIb>.so
]
Note: You can find some good reads here.
Upvotes: 1
Reputation: 6563
Define function prototypes in header .h file(s). And add library name to linker parameters.
Upvotes: 0