A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

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.so lib.c

gcc -o main main.c lib.so

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

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

please help :) .



Click Here!