Using concurrently 2 versions of boost

后端 未结 3 843
予麋鹿
予麋鹿 2020-12-18 22:47

I\'m using RHEL 5.3, which is shipped with gcc 4.1.2 and boost 1.33. There\'re some features I want, that are missing in the boost 1.33. Therefore the thought was to upgrad

3条回答
  •  猫巷女王i
    2020-12-18 22:59

    Update

    I think my original answer makes too many assumptions about the capabilities of the linker and the options used, and it may well be completely wrong. Ordinarily I would delete it, but there are some points in the discussion that aren't included in the other answers.

    I find the implications for what it takes to build a well behaved closed-source library just amazing.

    Original Answer

    As long as you use one version per compilation step then you should be OK because the code is generated at compile time and the generated symbols should be confined to the scope of the compilation step.

    I'm assuming that Boost is still a template library with no linkable libraries. If it isn't, then you're still OK as long as you don't link against more than one version of the library.

    I might be wrong on this, but the implication would be that you can't use any third party library built against a different version of Boost from the version defined for your application. Nothing that I've read or heard even hints that this limitation applies.

    If you are building your own application, then I would stick with one version of Boost for all of your own code. It doesn't have to be the same version that is supplied by RHEL.

    Update

    In comparison with Artyom's example, the scenario I am talking about is more like this:

    g++ -c -I/usr/include/boost_1.31 a.cpp
    g++ -c -I/usr/include/boost_1.39 b.cpp
    ar rcs liba.a a.o
    ar rcs libb.a b.o
    g++ -I/usr/include/boost_1.41 test.cpp liba.a libb.a -o test
    

    ... and now I understand Artyom's point, because it depends on whether the linker prefers symbols in the same library file or not.

提交回复
热议问题