shared library and -lpthread problem under solaris

shared library and -lpthread problem under solaris

Post by Kyle Saunde » Fri, 04 Sep 1998 04:00:00



Hello,

I'm developing under Sparc Solaris 2.6, SC 4.2 (from Visual Workshop 3.0).

I'm trying to create a shared library and use threads (-lpthread).  The
problem is that I can do one or the other, but not both.  I have a little
test program that calls some functions in my little test shared library.  The
library will make pthread calls, and the application may make pthread calls.

If I link -lpthread, when my program calls fopen(), the program halts with
the following error message:

libc internal error: _rmutex_unlock: rmutex not held.

If I do not link with pthread, then my program runs ok, but the pthread calls
are apparently stubbed out by libc.

Of course, if I create my library non-shared (ar/ranlib style), then there is
no problem.  But that is not a practical solution for our application.  I
need to be able to successfully use shared libraries with -lpthread.

I've enclosed my makefile below, as I suspect that I'm doing something wrong
there.  Any suggestions are most appreciated (especially source for a test
app, lib, makefile that shows me how it's done :-)

        - Kyle

all:    libfoo.so foo foomt

libfoo.so:      foolib.o
#       CC -G -o libfoo.so foolib.o -lpthread
        CC -G -o libfoo.so foolib.o
        cp libfoo.so /usr/lib/libfoo.so

foolib.o:       foolib.cpp foolib.h

foomt:  foo.o libfoo.so
        CC -o foomt foo.o -lfoo -lpthread

foo:    foo.o libfoo.so
        CC -o foo foo.o -lfoo

foo.o:  foolib.h foo.cpp

clean:
        rm foo.o foolib.o libfoo.so foo foomt

--


"Well?  Does anyone want to punch me in the throat?" - R. Parker

 
 
 

1. Will strip(debug shared library) == nodebug shared library ?

compiling the C++ code without debug option to produce object
files(.o) and then producing the shared library with them. Say, the
size of this library is SIZE_SO_NoD.

compiling the C++ code with debug option to produce object files(.o)
and then producing the shared library with them. Then, do 'strip
library_name'. Say, the size of this library is SIZE_SO_D.

Will SIZE_SO_NoD & SIZE_SO_D be exactly/almost equal ? If yes/no, why?
Also, what exactly 'mcs -d library_name' do? Does it reduce symbols
from the shared library which was produced without debug option also?

2. ASTVision 7L Modeline values

3. Help with building shared libraries with dependencies on other shared libraries

4. RH7.2 and Asus A7V mboard

5. Question: Inclusion of shared libraries during linking of shared libraries

6. Xserver after CTL/ALT/BackSpace not leaving graphic registers in good state

7. Shared library loading shared library.

8. ext2 statics

9. Solaris Shared Memory, Shared Libraries and Heap

10. Need a Shared Library Guru: beyond simple shared library question

11. When is a shared library not a shared library?

12. using thread-safe library code without -lpthreads

13. Problem creating shared library under Solaris 2.6