hello groups, i am trying to make a statically compiled executable of my application, which uses the pthreads library facilities. I am not able to link, i am getting much errors from the linker, of wich i would like to have some clue. to better isolate the problem i wrote a small program that reflects the problem.
the code is really simple: #include <pthread.h> class pthread_static_v { public: pthread_static_v(); pthread_static_v(const pthread_static_v&); ~pthread_static_v(); }; pthread_static_v::pthread_static_v() { pthread_t pid; int ret = pthread_create(&pid, NULL, (some function pointer), NULL); } pthread_static_v::pthread_static_v(const pthread_static_v& a){} pthread_static_v::~pthread_static_v(){} int main() { pthread_static_v a = pthread_static_v(); return 1; } and this is what i get after issuing: $ g++ -static threads_static.c -o threads_static /home/vzafiropoulos/tmp/ccOsS8sA.o(.text+0x11): In function `pthread_static_v::pthread_static_v()': : undefined reference to `pthread_create' /home/vzafiropoulos/tmp/ccOsS8sA.o(.text+0x22): In function `pthread_static_v::pthread_static_v()': : undefined reference to `pthread_exit' /home/vzafiropoulos/tmp/ccOsS8sA.o(.text+0x37): In function `pthread_static_v::pthread_static_v()': : undefined reference to `pthread_create' /home/vzafiropoulos/tmp/ccOsS8sA.o(.text+0x48): In function `pthread_static_v::pthread_static_v()': : undefined reference to `pthread_exit' /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../libstdc++.a(eh_alloc.o)(.data._ZZ18__gthread_active_pvE20__gthread_active_ptr+0x0): In function `__cxa_free_exception': ../../../../gcc-3.4.1/libstdc++-v3/libsupc++/eh_alloc.cc:98: undefined reference to `pthread_create' /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../libstdc++.a(eh_alloc.o)(.text.__cxa_allocate_exception+0x4b): In function `__cxa_free_exception': /root/gcc_build/i586-mandrake-linux-gnu/libstdc++-v3/include/i586-mandrake-linux-gnu/bits/gthr-default.h:96: undefined reference to `pthread_create' /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../libstdc++.a(eh_alloc.o)(.text.__cxa_free_exception+0x38): In function `__cxa_free_exception': ../../../../gcc-3.4.1/libstdc++-v3/libsupc++/eh_alloc.cc:139: undefined reference to `pthread_create' /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../libstdc++.a(eh_globals.o)(.data._ZZ18__gthread_active_pvE20__gthread_active_ptr+0x0): In function `__cxa_get_globals': ../../../../gcc-3.4.1/libstdc++-v3/libsupc++/eh_globals.cc:49: undefined reference to `pthread_create' /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/../../../libstdc++.a(eh_globals.o)(.text.__cxa_get_globals+0x45): In function `__cxa_get_globals': /root/gcc_build/i586-mandrake-linux-gnu/libstdc++-v3/include/i586-mandrake-linux-gnu/bits/gthr-default.h:95: undefined reference to `pthread_create' /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.1/libgcc_eh.a(unwind-dw2.o)(.text+0x139c):../../gcc-3.4.1/gcc/gthr-posix.h:95: more undefined references to `pthread_create' follow collect2: ld returned 1 exit status i tried various combnations of "/usr/lib/libpthread.a" or "-pthread" into the compile/link line, but with no luck. furthermore, dynamically linking the code has positive results. i am starting to suspect that i have a big problem with glibc/pthreads/stdlibc++ configuration... can anyone help? thank you all, vasilis. _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus