2

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.

ondrousn
  • 57
  • 5

2 Answers2

1
  1. #include the header file containing the declaration of the function(s) you want to use in your main file.

  2. 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.

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
0

Define function prototypes in header .h file(s). And add library name to linker parameters.

i486
  • 6,491
  • 4
  • 24
  • 41