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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:49:41+00:00 2026-05-13T20:49:41+00:00

I am working in Linux, Eclipse CDT, g++, with Boost library. Having existing program

  • 0

I am working in Linux, Eclipse CDT, g++, with Boost library. Having existing program which uses Boost thread, I try to link it statically instead of dynamically. /usr/local/lib directory contains the following files:

libbost_thread.a
libbost_thread.so
libbost_thread.1.41.0

Dynamic linking works:

g++  -o"MyProgram"  ./main.o   -lboost_thread

Static linking:

g++ -static -o"MyProgram"  ./main.o   -lboost_thread

produces huge number of messages like:

undefined reference to `pthread_mutex_init’

How can I link statically to the Boost library?

  • 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-13T20:49:41+00:00Added an answer on May 13, 2026 at 8:49 pm

    For pthread_mutex_init, you want to compile/link with -pthread option:

    g++ -static -pthread -o"MyProgram"  ./main.o   -lboost_thread
    

    The problem is that functions like pthread_mutex_init are in a separate library. Dynamic libraries can include the metadata for the fact that it needs the separate library (so libboost_thread.so includes the fact that it needs libpthread).

    But static libraries don’t have that information. So you need to provide the reference to any necessary libraries when you link statically.

    As for using -pthread instead of -lpthread, it’s slightly preferable because it not only links the necessary library, but provides any other options that should be used (such a -D_REENTRANT to the compiler).

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

Sidebar

Related Questions

My working environment is Linux, Eclipse CDT and g++ 4.4. Where can I find
I'm working on a C++ project with eclipse Indigo + CDT running on linux
I'm working on linux + eclipse. I have updated my code following the steps
Working under linux for our developement, I have an Eclipse Makefile C Project and
I have Developed an Stand alone application (.jar) which is working on Linux environment,
i am working on Ubuntu10.10 OS and i have downloaded eclipse-jee-helios-SR1-linux-gtk-x86_64.tar.gz. my computer is
I am working on project in Linux which involves 1) Static Lib in C++
i have just install Eclipse PDT on my linux desktop computer. i am working
I have a working program on eclipse but my professor plans on running it
My Java program is in working order when i use it under Windows(Eclipse and

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.