LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-16-2004, 07:21 AM   #1
mmiglia
LQ Newbie
 
Registered: Sep 2004
Posts: 2

Rep: Reputation: 0
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.

What more?

here is the source

#include <iostream>
#include <unistd.h>
#include <pthread.h>

using namespace std;

void *run(void *arg)
{
cout << "Io sono in run\n";
int i = 0;
while(1)
{
cout << "io sono il thread " << i++ << "\n";
sleep(1);
}
}

int main(int argc, char** argv)
{
int i = 0;
for(i=1;i<argc;i++)
{
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";

while(1)
{
cout << "io sono il main " << i++ << "\n";
sleep(1);
}
}


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

--Mauro
 
Old 09-16-2004, 07:53 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
It would appear that this is a bug with the static version of the libraries, caused by using a vfork instead of a fork (for whatever reason).

Ref: http://sources.redhat.com/ml/bug-gli.../msg00120.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
libpthread.so.0? reeseslover531 Linux - Software 1 11-13-2005 05:51 AM
Installing Libpthread NewStudent Linux - Software 3 09-19-2005 01:07 PM
update libpthread kernelvn *BSD 1 07-01-2005 11:23 AM
libpthread.so.0(GLIBC_2.3.2) feathersmcgraw Linux - Newbie 4 02-17-2005 02:09 AM
UT2003 - anyone know anything about libpthread? kabads Linux - General 1 10-24-2002 09:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration