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

The Archive Base Latest Questions

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

I am using the Boost library in Linux, GCC. After installing and building the

  • 0

I am using the Boost library in Linux, GCC. After installing and building the Boost, I found that programs using Regex and Thread use shared Boost libraries. For my purposes, I need static linking.
How can I change linking type? Should I rebuild the Boost, or maybe I can set linking type by defining some constant in my own projects or Boost configuration files?

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

    Just add -static to your build invocation. Here is a quick example session:

    $ cat boost_formatted_time.cpp
    #include <iostream>
    #include <boost/date_time/posix_time/posix_time.hpp>
    #include <boost/date_time/posix_time/posix_time_io.hpp>
    
    using namespace boost::posix_time;
    using namespace std;
    
    int main(int argc, char **argv) {
      time_facet *facet = new time_facet("%d-%b-%Y %H:%M:%S");
      cout.imbue(locale(cout.getloc(), facet));
      cout << second_clock::local_time() << endl;
    }
    $ g++ -o /tmp/bft_dyn boost_formatted_time.cpp -lboost_date_time
    $ g++ -static -o /tmp/bft_stc boost_formatted_time.cpp -lboost_date_time
    $ ls -lh /tmp/bft_*
    -rwxr-xr-x 1 edd edd 216K 2010-02-24 12:34 /tmp/bft_dyn    
    -rwxr-xr-x 1 edd edd 1.5M 2010-02-24 12:34 /tmp/bft_stc    
    $ /tmp/bft_dyn
    24-Feb-2010 12:34:55
    $ /tmp/bft_stc
    24-Feb-2010 12:34:59
    $
    

    Note how the static binary is 1.5mb as opposed to 216kb for the dynamically-linked variant.
    All done on Debian testing with the default Boost packages.

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

Sidebar

Related Questions

I've been using Boost::regex and Boost::regex_search and found that when I run the regex
I am writing a Graph-class using boost-graph-library. I use custom vertex and edge properties
What are the differences in using boost:thread, Posix Thread library and the new C++11
I have gcc 4.4.5 and the latest boost library. I want to use boost
I am using the Boost::FileSystem library with C++ running under Linux platform and I
I'm using the boost::thread library (V1.44) to support threads in my C++ project. The
I'm using boost library for regular expression, I used boost::regex() function to compile the
on linux, gcc 4.3, compiling a class with boost::thread implementation and mutexes / condition
I am using the boost regex library in my code. I have a simple
I'm using the boost graph library and having a runtime error that I can't

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.