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 7858109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:16:26+00:00 2026-06-02T21:16:26+00:00

I am learning to create shared libraries in Linux, subsequently to develop parallelised scientific

  • 0

I am learning to create shared libraries in Linux, subsequently to develop parallelised scientific computing programs. I took the toy example from here for shared library. I modified the Makefile from this question to suit the toy example. My Makefile now is

CC        = mpicc

INCDIR    = -I ./

CFLAGS    = -Wall -rdynamic -g -fPIC $(INCDIR)

LIBADD    = -L ./ -lcalc_mean

all: dyn_main.out

dyn_main.out: libcalc_mean.so
    $(CC) -o $@ main.c $(LIBADD)

libcalc_mean.so:    calc_mean.o
    $(CC) -shared --export-dynamic -o $@ $<

calc_mean.o: calc_mean.c
    $(CC) $(CFLAGS) -c $<

clean :
    -rm *.o
    -rm *.out
    -rm *.so

.PHONY:
    clean

When I make with CC = gcc in the Makefile, things run fine. I could run the binary even with mpirun.

When I have CC = mpicc in the Makefile, I get the following error.

mpicc -Wall -rdynamic -g -fPIC -I ./ -c calc_mean.c
mpicc -shared --export-dynamic -o libcalc_mean.so calc_mean.o
mpicc -o dyn_main.out main.c -L ./ -lcalc_mean
/home/elan/localinstalls/lib/libmpi.so: undefined reference to `pthread_key_create'
/home/elan/localinstalls/lib/libmpi.so: undefined reference to `pthread_getspecific'
/home/elan/localinstalls/lib/libmpi.so: undefined reference to `pthread_create'
/home/elan/localinstalls/lib/libmpi.so: undefined reference to `pthread_atfork'
/home/elan/localinstalls/lib/libmpi.so: undefined reference to `pthread_setspecific'
/home/elan/localinstalls/lib/libmpi.so: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
make: *** [dyn_main.out] Error 1

I added the path to libpthread.so,.a to LD_LIBRARY_PATH, but no avail. I have a self compiled openmpi-1.5.4. If this were a openmpi dependency, shouldn’t it have been resolved when I configured it?

Is this error familiar? I am using Ubuntu 11.04, with gcc 4.5.2. I already built and run some mpi parallel programs successfully. But they are large packages configured with autotools. One of the config.log s display the same error. But even that one runs fine.

References to / examples of creating static/shared libraries with mpi will also be appreciated (though Openmpi discourages fully static libraries.)

Thank you very much,

Elan.


  • 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-06-02T21:16:29+00:00Added an answer on June 2, 2026 at 9:16 pm

    You should be able to just add -lpthread.

    Open MPI probably didn’t add it because it found that adding -lpthread wasn’t necessary (likely due to some other dependency implicitly pulling in the pthread library). But with the linker flags you’re using, you might well have changed that implicit dependency, so the pthread library isn’t being pulled in automatically anymore.

    If adding -lpthread to the command line fixes the issue, then see this FAQ entry for how to update the wrapper compilers (E.g., add your own flags): http://www.open-mpi.org/faq/?category=mpi-apps#override-wrappers-after-v1.0

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

Sidebar

Related Questions

I'm learning Objective-C using GNUstep(because I use Linux). I was thinking in create a
Just experimenting and learning, and I know how to create a shared dictionary that
I am learning to create RESTful services using WCF. There are a myriad of
How does Udacity.com (new learning website) create presentation where the text is in front
I've been learning how to create WP plugins and I can for the most
Just wondering if anyone has some good resources for learning how to create new
I learning Perl and I want to create a simple application that gets all
I am learning Cocoa and trying to create an application for Mac that displays
I am learning PyQt and wonder if one can create custom/owner draw control like
I'm trying to create my own template for a List class as a learning

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.