mardi 30 janvier 2018

Using c++11 legacy library in a C++17 project: compiler & linker problems

I am working in a project based on C++17 and have to rely on a library built with C++11 (or older). Problems arise from the fact that several structs have been removed for good from std with C++17. Note that I am building the legacy library from source!

The problems:

  • If I am building the library with C++11 and use it in the C++17 project, the linker won't find the correct implementations (e.g. string). That makes sense, since listing the library symbols I can see it references std::c++11::basic_string.
  • If I am trying to build the library with C++17, the compiler does not find the missing C++03 structs (e.g. ptr_fun). Again makes sense, as they are not part of the C++17 stdlib.
  • If I am trying to build the library with C++17 but include headers from C++11, everything explodes. Makes sense since the headers are not compatible.

Long story short, I do not see how to easily solve this. Technically, since I am able to build the library from source, there should be no definitive reason why I cannot use it with any other project. What's the best practice for this?

I am using Linux with clang for this. The question should be the same with any compiler and OS though.

Aucun commentaire:

Enregistrer un commentaire