简体   繁体   中英

Boost Linking Issues - Multiple Versions

I am writing a C++ application that has to read a binary .MAT file. So I need to use libmat and libmex to do this (note I am not using MEX files though). I am also trying to use boost::program_options to handle parsing command line arguments since this is a non-GUI application. I am using CMake to handle my build environment.

The version of boost we are working with is 1.59. However, when I try to link in program_options, CMake is finding the boost::program_options library in with the MATLAB libraries and the MATLAB libraries require boost 1.49. Then when I try to run the compiled application, it crashes because of using headers from 1.59 but the libraries from MATLAB's copies of 1.49. Does anybody have any ideas how I can use the two versions of boost since MATLAB will not work with 1.59 and MATLAB did not include the include files for 1.49.

If your application crashes, it means that sadly 1.49 and 1.59 are not binary compatible, so the only way this can work is that you force your application to use 1.59. There might be two options:

  • Force CMake to use 1.59 libraries, by setting BOOST_LIBRARYDIR variant to CMake.
  • Force CMake to use 1.59 libraries, and static versions of them, by additionally setting Boost_USE_STATIC_LIBS .

I don't actually use CMake, and FindBoost.cmake appears to not always be up-to-date, so I'm not 100% sure the static option will work, but give it a try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM