简体   繁体   中英

Include Boost library with executable binary

I have an issue where I'm developing on one system where Boost is installed on:

/usr/include
/usr/lib

On a system I will deploy this on, the libboost libraries are at:

/nfs/mount/boost
/nfs/mount/lib

And I can't go about changing every system I deploy on to install libboost in the same place.

Is there a way to either:

  1. include libboost as part of the binary executable such that loading from the system lib paths is not needed.
  2. make the executable search for different directories when trying to load to libboost?

I'm using g++ 8

Sounds like you need a more sophisticated build environment.

I'm not sure what you mean here:

  1. include libboost as part of the binary executable such that linking is not needed

Linking is not something you can skip. If you are trying to avoid distributing .dll/ .so files with your executable, you need to avoid using the portions of the boost library that require compilation of the boost binaries (ie those not listed here https://www.boost.org/doc/libs/1_62_0/more/getting_started/windows.html#header-only-libraries ).

Of course, that is not often the case. So...

  1. make the executable search for different directories when trying to link to libboost?

This will never work reliably as you scale and is a nightmare in the CI world. This is where package managers such as conan ( https://conan.io/ ) come to save the day. Delegating the package management to a third-party is the most reliable way of getting your code to build across multiple environments/platforms.

Also, building your executable and distributing it are separate operations. Any dynamically linked libraries will need to be discoverable on the system path at runtime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM