简体   繁体   English

提升链接问题-多个版本

[英]Boost Linking Issues - Multiple Versions

I am writing a C++ application that has to read a binary .MAT file. 我正在编写一个必须读取二进制.MAT文件的C ++应用程序。 So I need to use libmat and libmex to do this (note I am not using MEX files though). 因此,我需要使用libmat和libmex来执行此操作(请注意,虽然我没有使用MEX文件)。 I am also trying to use boost::program_options to handle parsing command line arguments since this is a non-GUI application. 我也试图使用boost::program_options来处理命令行参数解析,因为这是一个非GUI应用程序。 I am using CMake to handle my build environment. 我正在使用CMake处理我的构建环境。

The version of boost we are working with is 1.59. 我们正在使用的boost版本为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. 但是,当我尝试链接program_options时,CMake会在MATLAB库中找到boost::program_options库,而MATLAB库则需要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. 然后,当我尝试运行已编译的应用程序时,由于使用了1.59的标头,但使用了MATLAB的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. 是否有人对我如何使用Boost的两个版本有任何想法,因为MATLAB无法在1.59上运行并且MATLAB不包含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. 如果您的应用程序崩溃,则意味着1.49和1.59不二进制兼容,因此,唯一可行的方法是强制您的应用程序使用1.59。 There might be two options: 可能有两个选择:

  • Force CMake to use 1.59 libraries, by setting BOOST_LIBRARYDIR variant to CMake. 通过将BOOST_LIBRARYDIR变量设置为CMake,强制CMake使用1.59库。
  • Force CMake to use 1.59 libraries, and static versions of them, by additionally setting Boost_USE_STATIC_LIBS . 通过额外设置Boost_USE_STATIC_LIBS ,强制CMake使用1.59库及其静态版本。

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. 我实际上并没有使用CMake,并且FindBoost.cmake似乎并不总是最新的,因此我不确定100%可以使用static选项,但是请尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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