Reputation: 157
I am trying to crate a shared object (.so) using gcc version 3.4.3 for Solaris 32 bit system. I was googling for flags required to create a shared object for solaris. In some of the posts , I see that "-shared" flag not used. Instead "-G" flag is used. I had an impression that "-G" flag is same as "-g", but it seems that "-G" is equivalent to "-shared". Am I correct?
The reason being that with SLES10 x86_64 systems, "-shared" flag was required to build .so.
I tried following:-
LIB=-L/lib -L/usr/local/lib -L/usr/lib
gcc -m32 -G -fPIC -o myapi.so.1 myapi.o $(LIB)
Do I need to change above to:-
gcc -m32 -shared -fPIC -o myapi.so.1 myapi.o $(LIB)
Update1 Helpful suggestion from @user562374 to use -shared flag.
If the shared object built using -shared is deployed on solaris machine using different compiler and if it is "statically" linked, will it cause any issues? When I say "statically" linked .so, I mean shared object is linked in make file rather then using "dlsym".
Upvotes: 0
Views: 1469
Reputation: 3917
-G num
Put global and static objects less than or equal to num
bytes into the small data or bss sections instead of the
...
If it's gcc, it's -shared
, because -G
has other uses.
Upvotes: 1