I guess I finally understand. but i still have problem in compiling one lib: 
libutil.so which
used the libpthread.a lib in c. I try to convert libpthread.a to .so, it seems strange 
but
when i load it:

ld -shared -o libpthread.so --whole-archive /local/usr/lib/libpthread.a
ldd -r libpthread.so
        statically linked

I think this is the main problem when i convert libutil.a to libutil.so and i try to 
load
libutil.so

[kwong@nit45 lib]$ ldd -r libutil.so
        libstdc++-libc6.1-2.so.3 => /usr/lib/libstdc++-libc6.1-2.so.3 (0x400d0000)
        libm.so.6 => /lib/libm.so.6 (0x4011f000)
        libc.so.6 => /lib/libc.so.6 (0x4013d000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
undefined symbol: pthread_cond_timedwait        (./libutil.so)
undefined symbol: pthread_create        (./libutil.so)
undefined symbol: pthread_join  (./libutil.so)
undefined symbol: pthread_cancel        (./libutil.so)
undefined symbol: sem_init      (./libutil.so)
undefined symbol: sem_init      (./libutil.so)
undefined symbol: sem_destroy   (./libutil.so)
undefined symbol: sem_post      (./libutil.so)
undefined symbol: sem_post      (./libutil.so)
undefined symbol: sem_wait      (./libutil.so)

in this case, i guess i can't just load libutil.so lib. I somehow need to link it with
libpthread.a to make a .so file. therefore i try to add objects in libutil.a to a copy 
of
libpthread.a and convert it to .so file but when i try to load it, i got a lot of new
undefined symbol.

undefined symbol: terminate__Fv (./libutil.so)
undefined symbol: __9strstreami (./libutil.so)
.......

my guess is pthread lib uses some other lib too!? and i really don't understand why i 
get
"statically linked" when i try to load libpthread.so. if I can make a executable file 
with
just -lpthread -lutil, how come i can't make a .so lib with it?

Cheers,
Kason

Joi Ellis wrote:

> On Mon, 30 Oct 2000, kason wong wrote:
>
> > Hi,
> >
> > thanks, but  I still have some problem when i tried to compile all lib into a 
>static lib.
> >
> > g++ -o libCOPS.a COPS.o -L/home/kwong/thesis/codes/lib -lcops -lutil -lpthread
> > /usr/lib/crt1.o: In function `_start':
> > /usr/lib/crt1.o(.text+0x18): undefined reference to `main'
> > collect2: ld returned 1 exit status
> > make: *** [libCOPS.a] Error 1
>
> You can't load a static lib, it has to be a shared lib.  Look back at that
> Makefile I posted for a working example.
>
> What's "main"?  If g++ can't find its symbols, the JVM sure won't load it,
> either.
>
> --
> Joi Ellis                    Software Engineer
> Aravox Technologies          [EMAIL PROTECTED], [EMAIL PROTECTED]
>
> No matter what we think of Linux versus FreeBSD, etc., the one thing I
> really like about Linux is that it has Microsoft worried.  Anything
> that kicks a monopoly in the pants has got to be good for something.
>            - Chris Johnson


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to