> Why don't you define the functions and types that you're using as
> "extern" and the dynamic linker should resolve these at runtime?
> Also, I'd recommend explicitly telling the compiler to create Position
> Independent Code (-fpic), otherwise runtime linking becomes hit-or-miss
> with different executables.
Um, an AIX-relevant response would be, reference the pthreads library
when you link (-lpthreads). AIX uses a different technique for runtime
linking, and _all_ code is PIC. The above statement applies to other
implementations of *nix.
FWIW, even if RTL is involved, the module containing the definitions
of these symbols would have to be available, and if they're in a
different unreferenced location, they'll never be found.
> > i can't compile aix shared object.
> > this is my test
> > $g++ test.o -o test.so -shared
> > but, error occured.
> > ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_init
> > ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
> > ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
> > ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> > information.
> > collect2: ld returned 8 exit status
> > because, pthread was not exported.
No, because pthreads weren't _imported_.
Quote:> > Of course,
> > $g++ test.o -o test.so -shared -lpthread
> > this is well doing.
> > but, i don't want to contain pthread in my shared object.
> > how can i export pthread in my shared object(do not contain).
The pthreads library is a dynamically loaded module. Simply using
-lpthreads should be adequate to create a reference, which you
can confirm via the "dump -Hv" command on test.so. The above
command line looks fine.
--
Gary R. Hook / AIX Kernel Development, IBM / These opinions are _MINE_
________________________________________________________________________
A piece of canvas is only the beginning
It takes on character with every loving stroke
This thing of beauty is the passion of an artist's heart
By God's design, we are a skin kaleidoscope "Colored people", dc Talk