pthread issue on OpenSUSE 10

View: New views
4 Messages — Rating Filter:   Alert me  

pthread issue on OpenSUSE 10

by Dima Rusyy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello!

I am working on an application that uses gcc-2.95 libs.
When linking I got the following error:
------------
../gcc-2.95/lib/libstdc++.a(isgetline.o): In function `istream::getline(char *, int, char)':
../gcc-2.95/linux/i686-pc-linux-gnu/libio/../../../gcc-2.95.3/libio/isgetline.cc:41: undefined reference to `_pthread_cleanup_push_defer(_pthread_cleanup_buffer *, void (*)(void *), void *)'
../gcc-2.95/linux/i686-pc-linux-gnu/libio/../../../gcc-2.95.3/libio/isgetline.cc:41: undefined reference to `_pthread_cleanup_push_defer(_pthread_cleanup_buffer *, void (*)(void *), void *)'
../gcc-2.95/linux/i686-pc-linux-gnu/libio/../../../gcc-2.95.3/libio/isgetline.cc:54: undefined reference to `_pthread_cleanup_pop_restore(_pthread_cleanup_buffer *, int)'
--------

I am linking with the following flags:
-L/usr/local/lib -liberty -lstdc++ -Wl,--export-dynamic  /usr/lib/libpcre.a  -lXm -lXp -lXext -lXt -lX11  -ldl -lm -lpthread
and with gcc4.1.0.

I am stuck up with this problem because I have not seen such on any redhat : from fc3 to fc6.
The same situation is on SuSe Linux Enterprise Server 10.

Thanks!

Re: pthread issue on OpenSUSE 10

by Ian Lance Taylor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dima Rusyy <dima.ru.com@...> writes:

> I am working on an application that uses gcc-2.95 libs.

You know that 2.95 is really old, right?

> When linking I got the following error:
> ------------
> ../gcc-2.95/lib/libstdc++.a(isgetline.o): In function `istream::getline(char
> *, int, char)':
> ../gcc-2.95/linux/i686-pc-linux-gnu/libio/../../../gcc-2.95.3/libio/isgetline.cc:41:
> undefined reference to `_pthread_cleanup_push_defer(_pthread_cleanup_buffer
> *, void (*)(void *), void *)'

It looks like this may come from libio/config/linuxapi1-libc-lock.h:

#define __libc_cleanup_region_start(FCT, ARG) \
  { struct _pthread_cleanup_buffer _buffer;                                 \
    if (_pthread_cleanup_push_defer != NULL) {                              \
      _pthread_cleanup_push_defer (&_buffer, (FCT), (ARG));                 \
    }

The problem would seem to be that the function is getting called as a
C++ function rather than a C function.  Perhaps it was once declared
in pthread.h but no longer is.  It may work to add something like this
to linuxapi1-libc-lock.h:

extern "C" void _pthread_cleanup_push_defer
  (struct _pthread_cleanup_buffer *, void (*)(void *), void*);

Ian

Re: pthread issue on OpenSUSE 10

by Dima Rusyy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, I really link with g++ but your recipe didn't help.

I also looked at /lib/libpthread.so and _pthread_cleanup_push_defer is properly defined there.
I can't get why g++ can't link it. This is just a common function that defined in library. No matter how I use it : in C or C++ application. I also tried with static libpthread_nonshared.a but the result is the same.

Thanks!



Re: pthread issue on OpenSUSE 10

by Ian Lance Taylor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dima Rusyy <dima.ru.com@...> writes:

> Thanks, I really link with g++ but your recipe didn't help.
>
> I also looked at /lib/libpthread.so and _pthread_cleanup_push_defer is
> properly defined there.
> I can't get why g++ can't link it. This is just a common function that
> defined in library. No matter how I use it : in C or C++ application. I also
> tried with static libpthread_nonshared.a but the result is the same.

The error message tells me that it is a name mangling problem.  Your
program is looking for the C++ mangled name.  The library only
provides the C name.  There is a missing extern "C" somewhere.  I have
no suggestions beyond that.

Ian