Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

pthread library and static linking

807578Feb 17 2003 — edited Feb 27 2003
Hi All,

I'm trying to link static this simple test application:
----------------------------------------------------------------------------------------
#include <stdio.h>
#include <pthread.h>

void mythread (void );
void mythreadexit (void *);

int main (int argc, char *argv)
{
int status;
pthread_t t1;

status = pthread_create (&t1, NULL, mythread, NULL);
if (status)
{
printf ("pthread_create() return %d\n", status);
exit (status);
}

status = pthread_join (t1, NULL);
if (status)
{
printf ("pthread_join() return %d\n", status);
exit (status);
}

return (0);
}

void mythread (void arg)
{
pthread_cleanup_push (mythreadexit, NULL);

sleep (10);

pthread_cleanup_pop (0);
}

void mythreadexit (void *arg)
{
pthread_exit (NULL);
}
----------------------------------------------------------------------------------------
[roberto@ultrasparc10 roberto]$ gcc -static -o t1 t1.c
Undefined first referenced
symbol in file
_getfp /var/tmp//cc0ZQVGL.o
ld: fatal: Symbol referencing errors. No output written to t1
collect2: ld returned 1 exit status

As you can see the _getfp() function is called on
/usr/include/pthread.h:pthread_cleanup_push() macro.
I've searched on /usr/lib for some missed libs but trying to nm
inside I got only one library where is defined this function on
libpthread.so as shown below:

[roberto@ultrasparc10 roberto]$ cd /usr/lib
[roberto@ultrasparc10 lib]$ nm libpthread.so|grep _getfp
0000000000003ca4 T _getfp
[roberto@ultrasparc10 lib]$ nm libc.so|grep _getfp
[roberto@ultrasparc10 lib]$ nm libc.a|grep _getfp
[roberto@ultrasparc10 lib]$ nm libpthread.a|grep _getfp
nm: libpthread.a: No such file or directory
[roberto@ultrasparc10 lib]$ nm -o * 2>&1|grep _getfp
libproc.so:000000000000cecc T Plwp_getfpregs
libproc.so.1:000000000000cecc T Plwp_getfpregs
libpthread.so:0000000000003ca4 T _getfp
libpthread.so.1:0000000000003ca4 T _getfp
libthread.so:0000000000015e50 T _getfp
libthread.so.1:0000000000015e50 T _getfp
libthread_db.so:00000000000036b4 T __td_thr_getfpregs
libthread_db.so:00000000000036b4 W td_thr_getfpregs
libthread_db.so.1:00000000000036b4 T __td_thr_getfpregs
libthread_db.so.1:00000000000036b4 W td_thr_getfpregs

My question is: how can I link static above pthread's program ?
Removing pthread_cleanup_push() is too simple I need it ;-)!

Thanks in advance.

Roberto Fichera.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2003
Added on Feb 17 2003
5 comments
1,962 views