1

I am trying to build my C++ project with Boost::iostreams and I get the following linker error:

 undefined reference to `boost::iostreams::zlib::deflated'

I checked that my cmake was able to find the boost libraries:

-- Boost version: 1.65.0
-- Found the following Boost libraries:
--   system
--   date_time
--   iostreams
--   regex

and Boost::iostreams is added as a dependency to my project.

What could have cause this?

I installed Boost 1.65 from source using ./bootstrap.sh command. When I type ./b2 I get the notification that there is no zlib:

- zlib                     : no  (cached)
- bzip2                    : no  (cached)
- lzma                     : no  (cached)
- iconv (libc)             : yes (cached)
- icu                      : no  (cached)
- icu (lib64)              : no  (cached)
- native-atomic-int32-supported : yes (cached)
- native-syslog-supported  : yes (cached)
- pthread-supports-robust-mutexes : yes (cached)
- compiler-supports-visibility : yes (cached)
- compiler-supports-ssse3  : yes (cached)
- compiler-supports-avx2   : yes (cached)
- gcc visibility           : yes (cached)
- long double support      : yes (cached)

Is this the cause of this linker error? If so, how can I build boost with zlib enabled?

motam79
  • 3,542
  • 5
  • 34
  • 60
  • The library is called "zlib", not "zlip". – melpomene Aug 27 '18 at 12:45
  • The first step would be to install zlib-dev on your machine (i.e. the library plus the necessary header files). Then reinstall boost, and you _should_ see `zlib : yes`. If that doesn't work, ask again... – DevSolar Aug 27 '18 at 12:48
  • 3
    I moved from Boost 1.66 to Boost 1.69 and received the same problem. In windows I have no linker problem but in Linux I do. I fixed it by including the 'zlib.cpp' and 'gzip.cpp' in my project. These files are referenced in the boost iostreams documentation: https://www.boost.org/doc/libs/1_69_0/libs/iostreams/doc/installation.html. Boost 1.69 is the first time in Linux that I've had to included these files in my project and I only included them as a last resort. I've not yet figure out the reason and the documentation says the files are not needed under Linux. – DannyK May 20 '19 at 21:45
  • @DannyK can you please add this as an answer? It will help future visitors. – analytical_prat Jul 30 '23 at 15:15

0 Answers0