Linux下编译Boost 1.66时无法生成bzip2相关库文件问题
Hey there, let's dig into why your Boost 1.66 build isn't generating the bzip2-related libraries in /home/steve/boost_1_66_0/stage/lib, even though the log says zlib and bzip2 are "cached enabled". Here's what's likely going on and how to fix it:
Common Causes & Fixes
1. Your system is missing the bzip2 development packages
Boost's build system will report "cached enabled" for bzip2 if it detects the library's existence during the initial bootstrap, but if you only have the runtime bzip2 library (not the header files and development libraries), it won't actually compile the Boost bzip2 wrapper.
To fix this, install the bzip2 development package for your distro:
- For Debian/Ubuntu-based systems:
sudo apt-get install libbz2-dev - For RHEL/CentOS:
sudo yum install bzip2-devel - For Fedora:
sudo dnf install bzip2-devel
2. Clean existing build artifacts and recompile
The "cached enabled" status might be leftover from a previous build where bzip2 dependencies were missing. Let's start fresh:
- Clean the existing build files:
./b2 clean - Re-run bootstrap to ensure it properly detects the newly installed bzip2 dev files:
(If your bzip2 is installed in a non-standard path, add./bootstrap.sh--with-bzip2=/path/to/bzip2to the bootstrap command.) - Recompile Boost:
./b2
3. Verify the build log details
Take a closer look at the compile log—search for lines mentioning bzip2. You should see entries like:
checking for bzip2... yes
building boost_bzip2
If you don't see these lines, it means the build system still isn't finding the bzip2 development files, and you may need to specify the path explicitly during bootstrap.
Why Windows has the files but Linux doesn't
The official Windows precompiled Boost binaries come bundled with all required dependencies (like bzip2) out of the box. On Linux, Boost's build system relies on system-installed libraries to keep the build lightweight, so you need to manually install the development packages first.
内容的提问来源于stack exchange,提问作者Stepan Yakovenko

