Ubuntu环境下无法编译Boost 1.47.0 IOStreams库问题求助
Hey, I’ve dealt with this exact problem when working with older Boost versions like 1.47.0—your issue is almost certainly missing development libraries for zlib and bzip2. Even though you have the basic binaries and headers, Boost’s build system needs the full development packages to compile the iostreams library properly.
Step 1: Install the Required Development Packages
Depending on your Linux distro, run the appropriate command to grab the missing dev packages:
- Debian/Ubuntu-based systems:
sudo apt-get install zlib1g-dev libbz2-dev - RHEL/CentOS/Fedora-based systems:
sudo yum install zlib-devel bzip2-devel
Step 2: Recompile Boost (Target iostreams or Full Build)
To save time, you can compile just the iostreams library instead of rebuilding everything:
./b2 --toolset=gcc variant=debug --with-iostreams
If you want a full clean rebuild of all libraries, use:
./b2 --toolset=gcc variant=debug clean all
Troubleshooting If It Still Fails
If the dev packages don’t fix it immediately, you can manually specify the paths to zlib and bzip2 for Boost’s build system:
./b2 --toolset=gcc variant=debug \ -sZLIB_INCLUDE=/usr/include \ -sZLIB_LIBPATH=/usr/lib \ -sBZIP2_INCLUDE=/usr/include \ -sBZIP2_LIBPATH=/usr/lib \ --with-iostreams
(Note: For 64-bit systems, replace /usr/lib with /usr/lib64 if that’s where your system stores 64-bit libraries.)
Verify the Result
Once the build finishes, check your Boost installation’s lib directory—you should see files like libboost_iostreams-gcc*-debug.a (the exact name depends on your GCC version) which confirms the static library compiled successfully.
内容的提问来源于stack exchange,提问作者Josh

