what's the difference between libpthread.so and libpthread.a?
Hi to everyone.
I know the short answer dynamic vs static linking, however, I need a deeper answer because I have a short, stupid test program that works as expected when dynamically linked while sigsegv inside pthread_create when statically linked.
here is the source
using namespace std;
void *run(void *arg)
cout << "Io sono in run\n";
int i = 0;
cout << "io sono il thread " << i++ << "\n";
int main(int argc, char** argv)
int i = 0;
cout << argv[i] << "\n";
pthread_t *ilThread = (pthread_t*)malloc(sizeof(pthread_t));
cout << "Crea il thread...\n";
cout << "Crea il thread ma per davvero...\n";
cout << pthread_create(ilThread, (pthread_attr_t*)NULL, run, (void*)NULL) << "\n";
cout << "Creato il thread, entro in loop\n";
cout << "io sono il main " << i++ << "\n";
The distribution is fedora release 2 (kernel 2.6)
The compile command that works is:
g++ hello.cpp -lpthread -o hello
The one that does not is:
g++ hello.cpp -static -lpthread -o hello
Thanks in advance and best regards