badrobit
badrobit

Reputation: 793

External Library Boost Version Problems

I have an external library from a project I worked on that was compiled against boost 1.55; I have moved onto another project that needs to use this library but the current system is using boost 1.58.

When I link against the library it complains that it has missing references for boost 1.55 libraries. The library I am linking against was compiled using the following find_package command:

find_package( Boost 1.55 COMPONENTS ... REQUIRED )

I know there is a min command for CMake but I am not sure if this will allow me to use the library which was compiled against boost 1.55 on a machine currently running 1.58.

Any advice on how to compile this external library so that it will use any version of boost that is compatible with 1.55 would be very appreciated!

find_package command for the new program trying to find boost):

find_package( Boost 1.55 COMPONENTS system filesystem chrono regex thread date_time REQUIRED )

The system the new program is on has boost 1.58 not 1.55 so it outputs the following:

-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   chrono
--   regex
--   thread
--   date_time
--   atomic

The compile works fine against 1.58 it is only when the new program is linked against the library (compiled against 1.55) that it complains about not being able to find the boost 1.55 libraries (see below).

Linking output: (new program linking to library)

/usr/bin/ld: warning: libboost_system.so.1.55.0, needed by library.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_filesystem.so.1.55.0, needed by library.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_chrono.so.1.55.0, needed by library.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_regex.so.1.55.0, needed by library.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_thread.so.1.55.0, needed by library.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libboost_date_time.so.1.55.0, needed by library.so, not found (try using -rpath or -rpath-link)

Upvotes: 0

Views: 636

Answers (1)

Mike Kinghan
Mike Kinghan

Reputation: 61337

find_package( Boost 1.55 COMPONENTS ... REQUIRED )

will be satisfied if its finds any version of Boost >= 1.55.

find_package( Boost 1.55 EXACT COMPONENTS ... REQUIRED )

would only be satisfied with Boost 1.55.

Therefore if you simply rebuild the library with the same CMakeLists in the presence of Boost 1.58 it should be good.

Later

I am trying to come up with a method that I can compile the library once (say using boost 1.55) in a manner so that if on another system that is running a new version of boost say 1.58; won't complain about not having the 1.55 boost library when it has the 1.58 version of the boost libraries available

You can't do that:

find_package( Boost 1.55 COMPONENTS ... REQUIRED )

will allow you to build the library with boost 1.55 or later but the library you build will be dynamically linked with the boost version that is in fact found, and that dynamic linkage is baked into the binary by way of information for the OS loader.

So if you take that library to some system where boost 1.55 is absent you will get linkage errors such as you have seen when you try to link the library with anything else.

Regretably, you will have to build this library in the presence of boost 1.58 to link it with anything on a system that's at boost 1.58.

Upvotes: 1

Related Questions