Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

pthread

Posted on 1999-01-23
2
Medium Priority
?
615 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 150 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

618 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