-static -lX11 breaks pthreads (4.6)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jay K
Date: Monday, July 26, 2010 - 4:06 am

I haven't tried 4.7 yet.

OpenBSD xobsd.jkhome 4.6 obj#0 i386
$ cat 1.c
#include <stdio.h>
#include <pthread.h>

void* thread1(void* a)
{
  printf("%p\n", pthread_self());
  return 0;
}

int main()
{
  pthread_t t1;

  printf("%p\n", pthread_self());
  pthread_create(&t1, NULL, thread1, 0);
  sleep(100);
  return 0;
}

$ gcc 1.c  -L/usr/X11R6/lib -lX11 -pthread -static
$ ./a.out
0x0
0x0


I use -static deliberately so I can give binaries that work on other OpenBSD
versions.
I give source too, it's not too keep source private, but it is for "ease of
use".


Putting -lpthread (not -pthread) ahead of -lX11 fixes it.


I suppose there is a goal to enable using -lX11 without using -pthread?
And I suppose -static isn't meant to be much supported?
  Merging libpthread into libc is the way imho.


 - Jay
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
-static -lX11 breaks pthreads (4.6), Jay K, (Mon Jul 26, 4:06 am)
Re: -static -lX11 breaks pthreads (4.6), Ted Unangst, (Mon Jul 26, 7:30 am)
Re: -static -lX11 breaks pthreads (4.6), Jay K, (Mon Jul 26, 4:44 pm)
Re: -static -lX11 breaks pthreads (4.6), Philip Guenther, (Mon Jul 26, 7:14 pm)