Solved

pthread

Posted on 1999-01-23
2
609 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 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