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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:35:27+00:00 2026-05-30T23:35:27+00:00

I’ve this example code. #include <iostream> #include <boost/filesystem.hpp> using namespace std; int main() {

  • 0

I’ve this example code.

#include <iostream>
#include <boost/filesystem.hpp>
using namespace std;

int main()
{
  return 0;
}

It can be correctly build with: g++ -lboost_system-mt -lboost_filesystem-mt 1.cpp

But if I add -static, then it complains:

/tmp/cc1JEbRQ.o: In function `__static_initialization_and_destruction_0(int, int)':
1.cpp:(.text+0xb0): undefined reference to `boost::system::get_system_category()'
1.cpp:(.text+0xba): undefined reference to `boost::system::get_generic_category()'
1.cpp:(.text+0xc4): undefined reference to `boost::system::get_generic_category()'
1.cpp:(.text+0xce): undefined reference to `boost::system::get_generic_category()'
1.cpp:(.text+0xd8): undefined reference to `boost::system::get_system_category()'
collect2: ld returned 1 exit status

How do I fix that? Thanks

  • 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-30T23:35:28+00:00Added an answer on May 30, 2026 at 11:35 pm

    You probably need to reverse the order of your libraries for static linking to succeed, because boost_filesystem depends on boost_system:

    g++ 1.cpp -static -lboost_filesystem-mt -lboost_system-mt
    

    This is because the run-time linker does a topological dependency sort to load shared libraries in correct order, whereas static linking doesn’t do that.

    Alternatively, you can force static linking to do several passes over the list of libraries to try to resolve remaining undefined symbols:

    man ld:

       -( archives -)
       --start-group archives --end-group
           The archives should be a list of archive files.  They may be either
           explicit file names, or -l options.
    
           The specified archives are searched repeatedly until no new
           undefined references are created.  Normally, an archive is searched
           only once in the order that it is specified on the command line.
           If a symbol in that archive is needed to resolve an undefined
           symbol referred to by an object in an archive that appears later on
           the command line, the linker would not be able to resolve that
           reference.  By grouping the archives, they all be searched
           repeatedly until all possible references are resolved.
    
           Using this option has a significant performance cost.  It is best
           to use it only when there are unavoidable circular references
           between two or more archives.
    

    e.g:

    g++ 1.cpp -static -Wl,--start-group -lboost_system-mt -lboost_filesystem-mt -Wl,--end-group
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have this code to decode numeric html entities to the UTF8 equivalent character.
For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,

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.