Solved

pthread

Posted on 1999-01-23
2
595 Views
Last Modified: 2013-12-26
Hi:
I write a multi-thread application under Linux (Red Hat 5.1).
I use the pthread_create function. When I compile, it's OK. When I link the program, it said that that the pthread_create is unreferenced. So who will tel me what library should I link woth this program?
Who will offer me a makefile? (Just simple is OK)
Thanks.

0
Comment
Question by:jonalee
2 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1296367
-lpthread
0
 

Accepted Solution

by:
grepya earned 50 total points
ID: 1296368
Some of the  libraries have to be linked in explicitly when you compile your program containing one of the functions from that library. The library names are of the form lib<name>.so
for dynamic library and lib<name>.a for static libraries. So if you want to link against a library ( statically or dynamically)
with the name lib<name>.a or lib<name>.so, you append -l<name>
as the last option of your compiler invokation
( eg. cc threadtest.c -lpthread ) Whether a static or a dynamic link is done depends on how the compiler's defaults have been set up. Nowadays dynamic linking is the default in most cases.

  In your case, you are using functions which reside in the file
/usr/lib/libpthread.so ( in the RedHat distro..) The compiler knows where to look for the library file or if you have your library file in some other location for some reason, you can
give the -L/unusual/path/  as a compiler option. ( you should read the man pages for gcc etc for more details.)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now