1830234 Members
2516 Online
109999 Solutions
New Discussion

Building shared library

 
SOLVED
Go to solution
siba
Advisor

Building shared library

hi ,

when i am trying to build a shared library using the makefile which i have i get the error ld: Unsatisfied symbols:
$global$ (data)
localtime (code)
close (code)
memset (code)
__pthread_attr_init_system (code)
pthread_mutex_init (code)
pthread_mutexattr_destroy (code)
calloc (code)
system (code)
pthread_mutex_unlock (code)
strftime (code)
open (code)
free (code)
pthread_mutexattr_init (code)
fcntl (code)
malloc (code)
vsprintf (code)
SM_Trace (code)
gettimeofday (code)
write (code)
__pthread_create_system (code)
pthread_mutex_destroy (code)
pthread_mutex_lock (code)
ld: No $UNWIND_END$ subspace has been defined (probably missing /usr/ccs/lib/crt0.o)
*** Error exit code 1

the MAKEFILE has got the Foll options
CC_CMD=gcc -c
LD_SHAREDCMD=ld
LINK_FLAGS=
COMMONFLAGS=

it fails while builing the shared object though the .o files are built.
please help me

regards
shiva
10 REPLIES 10
H.Merijn Brand (procura
Honored Contributor
Solution

Re: Building shared library

LD_SHAREDCMD=ld -b

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
siba
Advisor

Re: Building shared library

thanks for replying. then i give -b option i get

ld -b plugin_util.o unixdef.o -o libSM_Utils.so
ld: DP relative code in file unixdef.o - shared library must be position
independent. Use +z or +Z to recompile.
*** Error exit code 1


any clues
Jean-Luc Oudart
Honored Contributor

Re: Building shared library

Your code must be compiled with +Z option for PIC code (ANSI compiler , man cc)

Rgds,
JL
fiat lux
Umapathy S
Honored Contributor

Re: Building shared library

Shiva,
You need to recompile files with +z or +Z option. Shared libraries can be built only with Position Independent code.

Add +z to your compiler rule in makefile.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
siba
Advisor

Re: Building shared library

sorry guys... i dont think i got u correctly.


my make file has the following options
the MAKEFILE has got the Foll options
CC_CMD=gcc -c
LD_SHAREDCMD=ld
LINK_FLAGS=
COMMONFLAGS=

libSM_Utils.so:$(OBJS)
$(LD_SHAREDCMD) $(LINK_FLAGS) $(OBJS) -o libSM_Utils.so

.c.o:
$(CC_CMD) $(COMMONFLAGS) $(INCLUDE_FLAG) -c $<

i tried giving +z in COMMONFLAGS i.e. COMMONFLAGS=+z but the same problem.

any help would be of great help.
Umapathy S
Honored Contributor

Re: Building shared library

Shiva,
You are using gcc. So use -fPIC during compilation.
COMMONFLAGS= -fPIC.
check man gcc for more details.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
siba
Advisor

Re: Building shared library

thanks for the response umapathy but i am sorry umapathy i forgot to mention that i have already created an alias for gcc as gcc -fPIC.

even if i give the -fPIC option in COMMONFLAGS it still gives me the same option.

can i use +Z option anywhere so that i dont get the ld error
siba
Advisor

Re: Building shared library

thanks it works... actually the problem was i had created an alias of gcc as gcc -fPIC -fpic which was wrong.
thanks a lot umapathy
ranganath ramachandra
Esteemed Contributor

Re: Building shared library

the flags are +z for cc/aCC and -fpic for gcc. if the linker says you should use +Z, the gcc equivalent flag is -fPIC.
 
--
ranga
hp-ux 11i v3[i work for hpe]

Accept or Kudo

Lev Assinovsky
Frequent Advisor

Re: Building shared library

If you use gcc for compiling then you
have to use gcc for LINKING either.
Command line:
gcc -shared -o libxxx.sl