0

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.

Suever
  • 64,497
  • 14
  • 82
  • 101
Todd
  • 90
  • 6
  • Possible duplicate of [Using boost in MATLAB MEX library, different from MATLAB's version](https://stackoverflow.com/questions/13934107/using-boost-in-matlab-mex-library-different-from-matlabs-version) – Alfonso Sancho Feb 27 '19 at 09:31

1 Answers1

0

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.

Vladimir Prus
  • 4,600
  • 22
  • 31
  • It looks like if we build 'boost' with it's version numbers in the name this could work, but unfortunately program_options and libmat must be calling the same routine and they conflict with each other. If they weren't calling the same routines, then it looks like I could mix versions of boost and make it work. I ended up using The Lean Mean C++ Option Parser. – Todd Apr 23 '16 at 00:20