This is the mail archive of the pthreads-win32@sourceware.org mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Static linking with pthread-win32 (again)


ä 2011/8/1 11:28, Eskes åé:
Hello,

I'm struggling with a problem for a while, and I can't figure it out.
I have a small test program (testpt.c) and I want to have it statically
linked with the pthread library. I use the latest TDM-4.5.2 MinGW
toolchain on WinXP (32) and I created the static lib from the cvs HEAD
version with the 'make clean GC-static' command and placed the
libpthreadGC2.a lib in the proper directory (in my case: /mingw/lib).
When I compile my testcase it keeps complaining about:

$ gcc -c testpt.c
$ gcc -o testpt.exe testpt.o -lpthreadGC2
testpt.o:testpt.c:(.text+0x29): undefined reference to `_imp__pthread_exit'
testpt.o:testpt.c:(.text+0x68): undefined reference to
`_imp__pthread_create'
testpt.o:testpt.c:(.text+0x86): undefined reference to `_imp__pthread_join'
collect2: ld returned 1 exit status

This problem has been mentioned before (mailing list 2010-07-23), Ross
Johnson claimed that this problem was fixed in the cvs head version.
When I create a DLL lib with 'make clean GC' all compiles and runs fine
when I put the genereted pthreadGC2.dll in the same directory. Do I
overlook something or missing a point somewhere? Any help is appreciated.

/* testpt.c (pthread static lib test) */
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void *f1(int *x){
int i = *x;
printf("f1: %d",i);
pthread_exit(0);
}

int main(void){
pthread_t f1_thread;
int i1 = 1;
pthread_create(&f1_thread,NULL,(void*)f1,&i1);
pthread_join(f1_thread,NULL);
return(0);
}

With regards,
John



If you use static edition, you must add the compiler option: -DPTW32_STATIC_LIB

As is :

gcc -DPTW32_STATIC_LIB -o testpt.exe testpt.o -lpthreadGC2


-- Best Regards, PcX


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]