1

I've just rebuilt boost 1.57 on Windows using MSVC because I want to add support for zlib:

.\b2 toolset=msvc-12.0 link=shared threading=multi address-model=64 --build-type=complete install -s NO_ZLIB=0 -s ZLIB_SOURCE=D:\zlib128

This builds fine and generates new files boost_zlib-vc120-mt-1_57.dll and boost_zlib-vc120-mt-1_57.lib.

I'm then using cmake to add boost to my project:

FIND_PACKAGE(Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS system date_time filesystem iostreams regex thread zlib)
if(Boost_FOUND)
    ADD_DEFINITIONS(${BOOST_DEFINITIONS} -DBOOST_ALL_NO_LIB)
    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
    LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
    TARGET_LINK_LIBRARIES(foobar ${Boost_LIBRARIES})
endif()

In Visual Studio, I see in "Additional Dependencies" that the boost_zlib-vc120-mt-1_57.lib is now also listed there. But trying to compile this example fails with a linker error:

Error 1730 error LNK2019: unresolved external symbol "int const boost::iostreams::zlib::default_compression" (?default_compression@zlib@iostreams@boost@@3HB) referenced in function "public: __cdecl boost::iostreams::detail::zlib_decompressor_impl >::zlib_decompressor_impl >(int)" (??0?$zlib_decompressor_impl@V?$allocator@D@std@@@detail@iostreams@boost@@QEAA@H@Z)

How can I fix this?

xtofl
  • 40,723
  • 12
  • 105
  • 192
Niko
  • 26,516
  • 9
  • 93
  • 110
  • Have you tried using auto linking? Remove `-DBOOST_ALL_NO_LIB`, if that works, then there's some library you haven't added to the list of required Boost libs. – Praetorian Jul 07 '15 at 19:42
  • @Praetorian Thanks, it does indeed work then. Any idea how I can figure out which library was missing? – Niko Jul 08 '15 at 06:01
  • [This](https://stackoverflow.com/q/31126324/241631) might help. – Praetorian Jul 08 '15 at 09:19

0 Answers0