Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7642269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:08:47+00:00 2026-05-31T09:08:47+00:00

In Linux, I have a shared library I made that uses pthreads and a

  • 0

In Linux, I have a shared library I made that uses pthreads and a main.c that does not.

libpthread.so shows up in an ldd of my shared library, which is correct.

$ ldd libmapreduce.so.1.0 
    linux-gate.so.1 =>  (0x0067d000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x0058c000)
    [...]

But when I compile and link my main.c that does not use pthreads to my shared library that does, I see:

$ icc -Wall -o main main.c -lmapreduce
    /opt/intel/Compiler/11.1/046/lib/ia32/libiomp5.so: undefined reference to `pthread_atfork'

Adding -lpthread to my compile command, i.e.,

$ icc -Wall -o main main.c -lmapreduce -lpthread

resolves the undefined reference.

Why do I need to explicitly link to libpthread when my main.c does not use it and my shared library already has libpthread linked in?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:08:48+00:00Added an answer on May 31, 2026 at 9:08 am

    Thank you R.. and Pavan Manjunath, for encouraging me to keep digging.

    The link step for the shared library libmapreduce.so looked like:

    icc -shared -g -o libmapreduce.so.1.0 map.o map_wrp.o -openmp [...] -lpthread -ldl
    

    That -openmp link flag was not needed and in fact introduced the undefined reference to pthread_atfork. The undefined reference to pthread_atfork did not show up until I tried to link a main.c with the shared library libmapreduce.so. Re-creating libmapreduce.so without the -openmp flag removed the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does Linux have a shared library that exports OS functions? msvcrt.dll -> libc.so.6 kernel32.dll
I have existing Linux shared object file (shared library) which has been stripped. I
I have created an sample shared library, that uses libcurl. Here is the corresponding
how to have a shared variable in library across all application in linux (c++)?
I have two shared libraries in Linux that when built are identical in all
I have implemented a shared library in Linux and try to test it, but
I have implemented multithreaded shared library in C++ (For Linux and Windows). I would
I have a shim library (shared, C++) which calls functions in another shared library
We have a Linux server application that is comprised of a number of open-source
We have a Linux application that makes use of OpenSSL's Python bindings and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.