views:

2318

answers:

1

Hello,

I have a shared library (*.so) created using Real View Compiler Tools (RVCT 3.2) on windows target. Then i try to link this *.so file with my application using gcc on linux system.

What is the gcc option to link this shared library with my application linux?

My question is the option -shared used as

gcc -shared myfile.so is used to create the so file or to link the so file? I believe its to create so is something like

gcc -lmyfile.so enough or is there any other switch to tell the linker that its a dynamic library(shared object)?

-AD

+1  A: 

gcc -lmyfile should be enough (provided that your library is named libmyfile.so). The linker searches for shared objects when possible and AFAIK prefers them.

jpalecek
I have a related question: In case my library libmyfile.so is a symlink to libyourfile.so, will linking my program using gcc -lmyfile still work? (I need to maintain backward compatibility of certain clients which are are unaware of the library name change.)
baskin