What is boost log, how to get it and how to build it

后端 未结 5 866
梦毁少年i
梦毁少年i 2020-12-24 02:10

So I heard good things about boost log. This claims its existence:

http://boost-log.sourceforge.net/libs/log/doc/html/index.html

This is the tutorial:

相关标签:
5条回答
  • 2020-12-24 02:26

    This is the method I followed to install Boost.Log in my Linux box. One important note before you build and install Boost libraries: Make sure you have installed a threading library like pthreads. Most package managers should have them.

    Here are the build steps:

    If you have installed Boost already from source, then its fine continue to next step. Otherwise download it from here (preferably the latest version (v1.46). I used v1.45). Extract the boost libraries at say: /opt. We can build the libraries along with Boost.Log.

    • Download Boost.Log from Sourceforge.
    • Extract the Boost.Log source archive in a folder – say /opt. Copy the log folder in: /opt/boost-log-1.0/boost to your boost source directory /opt/Boost_1_45_0/boost (assuming that you have extracted it in /opt).
    • Copy the log folder in: /opt/boost-log-1.0/libs to your boost libs directory /opt/Boost_1_45_0/libs (assuming that you have extracted it in /opt). If you haven’t installed other Boost libraries, then follow these steps:
      • cd /opt/Boost_1_45_0
      • .bootstrap.sh --show-libraries — this will list all the libraries that will be built and installed. You should see log listed as part of it.
      • .bootstrap.sh --with-libraries=all --prefix=/usr/local --includedir=/usr/local/include --libdir=/usr/local/lib
      • ./bjam install

    Finally make sure $LD_LIBRARY_PATH has /usr/local/lib (the path specified in bjam to install the built libraries) as part of it. If it is not edit your ~/.bashrc and add the following:

    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    export LD_LIBRARY_PATH
    
    0 讨论(0)
  • 2020-12-24 02:29

    Unknown symbol in text_file_backend.cpp at line 1197 while building boost-log-1-1 with boost 1.51.0

    I am using Windows MSVC 2010, but I suspect that the problem I had may be common to other platforms as well. I copied the boost.log sources into the boost 1.51 source tree and ran bootstrap.bat and .\b2 as per the instructions. The build failed, complaining that get_generic_category() is an unknown symbol in text_file_backend.cpp at line 1197

    I changed line 1197 of text_file_backend.cpp so that it now reads

    system::error_code(system::errc::io_error, system::generic_category()));
    

    and I re-ran the build. The build worked.

    I hope this helps someone else who has trouble building the boost-log library with boost 1.51

    Please see http://www.boost.org/doc/libs/1_51_0/libs/system/doc/reference.html#Deprecated-names for more information about this change.

    Edit: I just tried again using the boost-log sources direct from Subversion trunk, and it compiled OK. So the solution is: ignore boost-log 1.1 and use the Subversion trunk.

    0 讨论(0)
  • 2020-12-24 02:33

    If I interpret Andrew's answer correctly, his recommendation is to not use one of the packaged version of Boost.Log but do an SVN checkout from the boost-log SVN repository on SourceForge. I had a quick look at the files in the trunk there and can't find any reference to a v1.

    And no, I'm pretty sure that he isn't talking about John Torjo's Boost.Log v2, but a newer version of his Boost.Log that hasn't been packaged for a release yet.

    We are using Boost.Log and I'm pretty happy with it so far; your question actually helped me figure out what to do in order to build Boost.Log with 1.46.1...

    0 讨论(0)
  • 2020-12-24 02:34

    After lots of searching and testing this what I found out.

    • Download desired Boost (I tested it on stable release 1.51)

    • Checkout boost-log from here and copy <boost-log>/boost/log and <boost-log>/libs/log to <boost>/boost/log and <boost>/libs

    • Make sure you have a supported compiler (my problem was that!. It worked with gcc 4.1.7)

    • Run

      ./bootstrap.sh --with-libraries=all --prefix=<dir_to_install>
      

      and

      ./b2 address-model=32
      

    If everything goes according to plan, a directory <boost>/stage/libs will be created with the compiled libraries (including libboost_log.so)

    Notes:

    • I'm not sure why but prefix didn't work. I was expecting to see the libraries built there.

    • Use b2 not bjam.

    • No need to alter Jamfile in <boost-log>.

    • I got a bunch of warnings but no when building log.

    I hope it helps somebody.

    0 讨论(0)
  • 2020-12-24 02:47

    boost log v2 is simply what you get by checking out trunk, according to what Andrey says in the post you link.

    indeed, it seems that this version too has got problems compiling against boost::filesystem v3.

    if this is also your case, one workaround is compiling after adding

    <define>BOOST_FILESYSTEM_VERSION=2
    

    to the jamfile.

    if this does not work, then, check whether you are building a single threaded or multi-threaded version of the libraries. multi-threadred boost-log should be more tested (according to Andrey).

    hope this helps... I have not tried it...

    EDIT:

    where to add the ?

    I would add it to the requirements section of boost-log/libs/log/build/Jamfile.v2, shared subsection:

    project boost/log
        : source-location ../src
        : requirements
           <link>shared:<define>BOOST_LOG_DLL
           <link>shared:<define>BOOST_FILESYSTEM_VERSION=2
    

    EDIT: from Cookie's comment, BOOST_FILESYSTEM_VERSION=2 should be specified as

           <link>msvc:<define>BOOST_FILESYSTEM_VERSION=2
    

    not in shared.

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