dimanche 6 mars 2022

Get GCC to Remove C++ 11 Flag in Mangled Name

I'm debugging a build that links against JsonCpp and I get a linker error where the demangled name it's trying to link to is _ZNK4Json6Reader25getFormattedErrorMessagesB5cxx11Ev and the one the library provides is _ZNK4Json6Reader25getFormattedErrorMessagesEv. There's an extra code in the mangled name (B5cxx11) that the compiler added for some reason. How do I tell the compiler not to mangle in this C++ 11 flag?

This is the code around where the symbol is needed:

Json::Reader jreader;

if (jreader.parse(buffer.str(), value))
{
    ret = 0;
}
else
{
    ret = INPUT_PARSE_ERROR;
    std::cerr << jreader.getFormattedErrorMessages() << std::endl;
}

Environment: Ubuntu 20.04, GCC 9.3.0, CMake 3.16.3

Edit: I tried adding #define _GLIBCXX_USE_CXX11_ABI 0 to the top of the compilation unit and it makes this specific error go away, but causes a bunch of other linker failures.

Aucun commentaire:

Enregistrer un commentaire