Search code examples
c++linuxserializationboostbinaryfiles

Boost binary file read error unsupported version


I'm doing sequence of serialization.

In windows system, i made binary file through boost::serialization

it seems there is no problem.

But, if i moved this binary file to linux system and load binary file compiler says unsupported version.

I have no idea about this problem.

Can anyone help us?

Windows and linux Boost version is same. boost version is 1_63_0.

Adjcency_grpah LoadGraphData(char *fileName) {
    Adjcency_grpah g;
    std::ifstream ifs(fileName, std::ios::binary);
    if (!ifs) {
        cout << "Read Error" << endl;
        exit(1);
    }
    try {
        boost::archive::binary_iarchive ia(ifs);
        ia & BOOST_SERIALIZATION_NVP(g);
        cout << "Restoring Graphs Serialize Success\n" << endl;
    }
    catch (boost::archive::archive_exception e) {
        cout << "BOOST ERROR " << e.what() << std::endl;
    }
    return g;
}

It still says "BOOST ERROR unsupported version Time: 0"


Solution

  • Boost's builtin binary archive is not portable. It says so in the documentation.

    Instead, you should be able to use EOS Portable Archive. It's completely drop-in compatible with Boost Serialization.

    Besides this, be sure to use platform independent type identifiers (so, int64_t instead of long etc).