i wish to add one more thing here:

> The strange point is that, the LD_LIBRARY_PATH is not working, but -L option to gcc works -- I think they should be the same,

There is a subtle difference in how the static and shared libraries are linked during compile time and runtime.

For the shared lib, at compile time, the various symbols that have been used in the program will be matched with what is there in the .so file, u specify. But , the various object files that have been used to create the ".so" file will not be attached to the object code at this stage as against what is done in the static libraries..

At run time, the dynamic loader , scans the various paths that have been specified in the LD_LIBRARY_PATH. If your lib file isnt there in this path you get an error. that's why u have to use setenv or export and set the path to your ".so" file depending on the shell that u sseem to be using.

Atleast this is what i have understood. As i mentioned. I learnt this just yesterday..so, someone please correct me if i have gone wrong somewhere.