How to determine the Boost version on a system?

前端 未结 12 2201
暖寄归人
暖寄归人 2020-12-04 07:46

Is there a quick way to determine the version of the Boost C++ libraries on a system?

相关标签:
12条回答
  • 2020-12-04 08:06

    Tested with boost 1.51.0:

    std::cout << "Using Boost "     
              << BOOST_VERSION / 100000     << "."  // major version
              << BOOST_VERSION / 100 % 1000 << "."  // minor version
              << BOOST_VERSION % 100                // patch level
              << std::endl;
    

    Output: Using Boost 1.51.0

    Tested with boost versions 1.51.0 to 1.65.0

    0 讨论(0)
  • 2020-12-04 08:07

    If you only need to know for your own information, just look in /usr/include/boost/version.hpp (Ubuntu 13.10) and read the information directly

    0 讨论(0)
  • 2020-12-04 08:09

    As to me, you can first(find version.hpp the version variable is in it, if you know where it is(in ubuntu it usually in /usr/include/boost/version.hpp by default install)):

     locate `boost/version.hpp`
    

    Second show it's version by:

     grep BOOST_LIB_VERSION /usr/include/boost/version.hpp
    

    or

      grep BOOST_VERSION /usr/include/boost/version.hpp.
    

    As to me, I have two version boost installed in my system. Output as below:

    xy@xy:~$ locate boost/version.hpp |grep boost
    
    /home/xy/boost_install/boost_1_61_0/boost/version.hpp
    /home/xy/boost_install/lib/include/boost/version.hpp
    /usr/include/boost/version.hpp
    
    xy@xy:~$ grep BOOST_VERSION /usr/include/boost/version.hpp
    #ifndef BOOST_VERSION_HPP
    #define BOOST_VERSION_HPP
    //  BOOST_VERSION % 100 is the patch level
    //  BOOST_VERSION / 100 % 1000 is the minor version
    //  BOOST_VERSION / 100000 is the major version
    #define BOOST_VERSION 105800
    //  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
    
    # or this way more readable
    xy@xy:~$ grep BOOST_LIB_VERSION /usr/include/boost/version.hpp
    //  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
    #define BOOST_LIB_VERSION "1_58"
    

    Show local installed version:

    xy@xy:~$ grep BOOST_LIB_VERSION /home/xy/boost_install/lib/include/boost/version.hpp
    //  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
    #define BOOST_LIB_VERSION "1_61"
    
    0 讨论(0)
  • 2020-12-04 08:10

    Might be already answered, but you can try this simple program to determine if and what installation of boost you have :

    #include<boost/version.hpp>
    #include<iostream>
    using namespace std;
    int main()
    {
    cout<<BOOST_VERSION<<endl;
    return 0;
    }
    
    0 讨论(0)
  • 2020-12-04 08:15

    Boost installed on OS X using homebrew has desired version.hpp file in /usr/local/Cellar/boost/<version>/include/boost/version.hpp (note, that the version is already mentioned in path).

    I guess the fastest way to determine version on any UNIX-like system will be to search for boost in /usr:

    find /usr -name "boost"

    0 讨论(0)
  • 2020-12-04 08:17

    Another way to get current boost version (Linux Ubuntu):

    ~$ dpkg -s libboost-dev | grep Version
    Version: 1.58.0.1ubuntu1
    

    Ref: https://www.osetc.com/en/how-to-install-boost-on-ubuntu-16-04-18-04-linux.html

    0 讨论(0)
提交回复
热议问题