Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


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

Rep: Reputation: 0
what's the difference between 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;
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

Old 09-16-2004, 08:53 AM   #2
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).



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 reeseslover531 Linux - Software 1 11-13-2005 06:51 AM
Installing Libpthread NewStudent Linux - Software 3 09-19-2005 02:07 PM
update libpthread kernelvn *BSD 1 07-01-2005 12:23 PM feathersmcgraw Linux - Newbie 4 02-17-2005 03:09 AM
UT2003 - anyone know anything about libpthread? kabads Linux - General 1 10-24-2002 10:21 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:24 PM.

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