November 10, 2010

Linux Dynamic library command help



i have created a program in c language to use dynamic libraries with it.

i have a main.c file in which i have created two functions(i.e. just calling those function from the lib.c file where they are fully defined) and lib.c which contain the full function implementation and have a iib.h which contain those two function declarations.

Now i have type the following command

gcc -fPIC -shared -o lib.c

gcc -o main main.c

After that i have copied the file to the /usr/lib directory

But now i am confused how do execute my program in a way that it calls the file in the /usr/lib at runtime and then my program works.

please help :) .