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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:02:08+00:00 2026-05-16T14:02:08+00:00

I am using boost serialization on windows, and I wanted to test my code

  • 0

I am using boost serialization on windows, and I wanted to test my code on linux (ubuntu) and unfortunately it does not compile.

#include <string>
#include <fstream>

#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>


#include <boost/serialization/string.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/export.hpp>


class MyClass
{
  public:
    int something;
    MyClass();

    template<class archive> void serialize(archive& ar, const unsigned int version)
    {
      using boost::serialization::make_nvp;
      ar & make_nvp("something", something);
    }


};



MyClass::MyClass()
  : something(0)
{
}

int main(int argc, char ** argv)
{
  std::cout << "Hello";
  MyClass obj();

  std::string path = "here.xml";

  std::ifstream ifs(path.c_str());
  if (ifs.good())
  {
    boost::archive::xml_iarchive ia(ifs);
    ia >> boost::serialization::make_nvp("obj", obj);

    ifs.close();
    return true;
  }
  else
    return false;

}

Here is my compile line:

g++ test.cpp -lboost-serialization

And here is what I get:

In file included from /usr/include/boost/archive/detail/interface_iarchive.hpp:23,
                 from /usr/include/boost/archive/detail/common_iarchive.hpp:21,
                 from /usr/include/boost/archive/basic_xml_iarchive.hpp:23,
                 from /usr/include/boost/archive/xml_iarchive.hpp:24,
                 from test.cpp:6:
/usr/include/boost/archive/detail/iserializer.hpp: In function ‘void boost::archive::load(Archive&, const T&) [with Archive = boost::archive::xml_iarchive, T = MyClass()]’:
/usr/include/boost/archive/detail/common_iarchive.hpp:61:   instantiated from ‘void boost::archive::detail::common_iarchive<Archive>::load_override(T&, int) [with T = MyClass(), Archive = boost::archive::xml_iarchive]’
/usr/include/boost/archive/basic_xml_iarchive.hpp:81:   instantiated from ‘void boost::archive::basic_xml_iarchive<Archive>::load_override(const boost::serialization::nvp<T>&, int) [with T = MyClass(), Archive = boost::archive::xml_iarchive]’
/usr/include/boost/archive/xml_iarchive.hpp:75:   instantiated from ‘void boost::archive::xml_iarchive_impl<Archive>::load_override(T&, int) [with T = const boost::serialization::nvp<MyClass()>, Archive = boost::archive::xml_iarchive]’
/usr/include/boost/archive/detail/interface_iarchive.hpp:61:   instantiated from ‘Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = const boost::serialization::nvp<MyClass()>, Archive = boost::archive::xml_iarchive]’
test.cpp:48:   instantiated from here
/usr/include/boost/archive/detail/iserializer.hpp:570: error: no matching function for call to ‘load_wrapper(boost::archive::xml_iarchive&, MyClass (&)(), boost::serialization::is_wrapper<MyClass()>)’

I am probably missing an include…

  • 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-16T14:02:08+00:00Added an answer on May 16, 2026 at 2:02 pm

    You’ve encountered the Most Vexing Parse. In your main method, change

    MyClass obj();
    

    to

    MyClass obj;
    

    also, on my Linux system, the link line is

    g++ test.cpp -lboost_serialization
    

    Note the underscore instead of dash, like in your example

    g++ test.cpp -lboost-serialization
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using boost serialization with xml files with a C++ program. When I
I have a problem using boost serialization using binary archives. It works when using
I have just started using Boost 1.36. These libraries would be very useful in
I'm using boost for several C++ projects. I recently made a upgrade (1.33.1 to
I'm using boost's shared pointers, and enable_shared_from_this to enable returning a shared pointer to
What might be the best way to start programming using boost lambda libraries.
So I am doing a lot of high performance network programming using Boost::Asio (or
I am experiencing a crash while using the Boost.Spirit and Boost.Thread libraries in my
When using the pImpl idiom is it preferable to use a boost:shared_ptr instead of
How much do using smart pointers, particularly boost::shared_ptr cost more compared to bare pointers

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.