ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have just installed FedoraCore 4 using the default Workstation paackage profile and I cannot link programs that reference Posix calls like pthread_create(). I cannot find documentation on what my environment variables should be (I have /usr/include and /usr/lib). When I query 'getconf GNU_LIBPTHREAD_VERSION' I get: NPTL 2.3.5. Everything seems to be okay; I can even find pthread.h in /usr/include. What's missing?
A header file *.h in most cases only contains a definition of a function.
The body of a function is inside a precompiled library. So unless the function is inside the standard library, you need to specify the library your executable should be linked against. Otherwise you'll get undefined reference errors. All the pthread functions are in libpthread.so
so you need to specify -lpthread (you always omit the lib) when compiling something.
It should be documented in the guide you are using ( or maybe they thought it's obvious...)
I just assumed without any real justification that all Posix services were now in the default libraries and it didn't even occur to me that they might be in their own that required an explicit compiler switch. But yes, it would have been helpful for the author of the book to include that wee detail.
Anyhoo, that you very much for the help!
By the way, I have just spent the last two hours trying to figure out which library I need to link to to use the posix queue calls. I cannot believe this information is this difficult to discover, but no Google search I can think of gives me more than a mention of the mqueue.h header file. Do you know of a resource that discusses libraries?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.