[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: statically linking pthreads
From: |
VASILI3000 |
Subject: |
Re: statically linking pthreads |
Date: |
24 May 2006 02:23:49 -0700 |
User-agent: |
G2/0.2 |
Paul Pluzhnikov ha scritto:
> > i tried various combnations of "/usr/lib/libpthread.a" or "-pthread"
> > into the compile/link line, but with no luck.
>
> This should have worked. What were the errors?
the errors are the same i got not specifying the compiler flag
-pthread: lots of undefitned references to the pthread library
functions. maybe my build system is not sane...
>
> > furthermore, dynamically linking the code has positive results.
>
> Dynamic linking is what you *should* do, but static linking with
>
> $ g++ -static threads_static.c -o threads_static -pthread
>
> should have also worked (as in "produced correctly working but
> extremely non-portable executable").
the executable is meant for an embedded system, but as you can see i am
still in the first step:"can i produce a generic statically linked
executable on my machine?"
> > i am starting to suspect that i have a big problem with
> > glibc/pthreads/stdlibc++ configuration...
>
> I just tried 'g++ -static -pthread ...' on MDK-10, and came back with:
> /usr/bin/ld: cannot find -lstdc++
>
> If that's what you got, you need to install archive version of
> libstdc++ (this has nothing to do with pthreads -- you wouldn't
> be able to link any C++ program with -static if you don't have
> libstdc++.a).
i overcame all these problems. in fact, i had no static c++ library,
nor glibc and pthreads