How to Determine the Boost Version on a System

How to determine the Boost version on a system?

Boost Informational Macros. You need: BOOST_VERSION

how do you check your version of boost? [duplicate]

Well, take a look at your boost/version.hpp. There is BOOST_VERSION macro for that:

// Example: for boost 1.55.0, taken from 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 105500

Compiling C++ code on a system with two different Boost versions installed

You can confirm or disprove your suspicions by getting the linker to confess which libraries it is actually using. Add the option -Wl,--verbose to your g++ link command line (in the makefile or try this directly). The linker will then spit out which exact file was matched for everything it was trying to link, including your boost libraries.

If it turns out it is in fact linking the wrong versions, it also gives you a clue as to why exactly, by specifying the exact order of paths which the linker tries in locating a given library. This should give you some ammo should you need to change around some of your options (e.g. ordering and/or content of -L... and -l... options)

Should this fail, you can also use the option -l:/path/to/exact/libboost_whatever.so. This will force to use the linker the given version. I would try this last though.

Instruct CMake to choose right version for multiple Boost installation

You can check which boost was found either by having a look at the configure output or in the CMakeCache.txt file in your build directory. The configure output tells you the path where it has found Boost. In the CMakeCache.txt file you can search for BOOST_LIB* or BOOST_INCLUDE* and you should get the path to the library/headers. This will help to identify the version.

If you want to specify one of your two Boost installations, you an pass CMake the root directory of your Boost via BOOST_ROOT. This will look like

cmake -DBOOST_ROOT=/usr/local/boost_1.59 <otherstuff>

Compile with boost to use whatever boost version is available?

You cannot expect your program to work with a different version of the library.

The fact that there are /different/ versions implies that they're /not the same/.

As mentioned, either

  • statically link to your specific version, or
  • you can ship the shared libraries (as long as you put them in a app-specific location and make sure you find them at runtime). Incidentally, see the second example here: How to compile boost async_client.cpp for the relevant linker options to use a custom library (it assumes the same location is to be used at runtime (rpath)

Conflict between two boost versions

How your toolchain's header and library search paths are determined is implementation-specific. There is no universal rule for what environment variables, if any, affect them, or how.

The specific environment variables you are trying to use and the values you are setting for them indicate a UNIX-style system. You should be aware that

  • on such a system, the PATH variable sets the search path for executables, not libraries or headers.
  • on those systems that recognize it, LD_LIBRARY_PATH designates extra directories for the dynamic linker's search path -- these are relevant at run time, not build time.
  • CPLUS_INCLUDE_PATH is recognized by the GNU C++ compiler, and maybe others, for designating additional directories to search for include files. This is relevant to you for finding the Boost headers, but not the libraries. With GNU compilers, the directories listed in this variable will be searched before the standard directories.
  • LIBRARY_PATH is recognized by the GNU linker, and possibly others, as designating additional directories to search for libraries. Like CPLUS_INCLUDE_PATH, this is relevant to you, but it does not allow you to substitute your libraries for like-named others found in one of the standard locations, because the standard directories are searched before these.

Your error messages suggest that The linker is finding a mixture of Boost v1.53 and v1.64 libraries. Probably that means that the former reside in a directory that is search first -- likely a system directory such as /usr/lib -- but not all the Boost libraries you are trying to link are found there; some are found in your v1.64 installation. Given that what you've already tried does not work, there is unlikely to be any environment variable you can set to fix that. As I said, however, it's implementation-dependent, and although I suspect you're using the GNU toolchain, you haven't specified.

With the GNU toolchain, if you want the linker to search your personal Boost installation for libraries before it searches the standard directories then you'll need to instruct it specifically to do so via command-line option. As discussed in comments, you can accomplish that by adding -L/truba/home/osibliyev/boost/lib to your Automake LDADD variable.



Related Topics



Leave a reply



Submit