More specifically static boost::iostreams with zlib (aka libz) support.
The problem is, that when I try to link static library it throws unresolved symbols. At the same time when I try to link dynamic library everything works...
I've been searching for answer for several days and can't find it yet.
The command I use to build shared library: b2 -a -q -j8 address-model=32 toolset=gcc --with-iostreams link=shared runtime-link=shared -sZLIB_INCLUDE="path" -sZLIB_LIBPATH="path" -sBZIP2_INCLUDE="path" -sBZIP2_LIBPATH="path"
The command I use to build static library: b2 -a -q -j8 address-model=32 toolset=gcc --with-iostreams link=static runtime-link=static -sZLIB_INCLUDE="path" -sZLIB_LIBPATH="path" -sBZIP2_INCLUDE="path" -sBZIP2_LIBPATH="path"
Example of the program:
#include <iostream>
#include <boost/iostreams/filter/gzip.hpp>
int main(int argc, char* argv[]) {
int a = boost::iostreams::zlib::default_compression;
std::cout << a << std::endl;
return 0;
}
The exception I get:
D:\boost_1_72_0\stage\lib/libboost_iostreams-mgw63-mt-s-x32-1_72.a(zlib.o):zlib.cpp:(.text+0x124): undefined reference to `crc32'
D:\boost_1_72_0\stage\lib/libboost_iostreams-mgw63-mt-s-x32-1_72.a(zlib.o):zlib.cpp:(.text+0x181): undefined reference to `deflate'
D:\boost_1_72_0\stage\lib/libboost_iostreams-mgw63-mt-s-x32-1_72.a(zlib.o):zlib.cpp:(.text+0x1a1): undefined reference to `inflate'
D:\boost_1_72_0\stage\lib/libboost_iostreams-mgw63-mt-s-x32-1_72.a(zlib.o):zlib.cpp:(.text+0x1cc): undefined reference to `deflateReset'
D:\boost_1_72_0\stage\lib/libboost_iostreams-mgw63-mt-s-x32-1_72.a(zlib.o):zlib.cpp:(.text+0x1e5): undefined reference to `inflateEnd'
D:\boost_1_72_0\stage\lib/libboost_iostreams-mgw63-mt-s-x32-1_72.a(zlib.o):zlib.cpp:(.text+0x201): undefined reference to `inflateReset'
D:\boost_1_72_0\stage\lib/libboost_iostreams-mgw63-mt-s-x32-1_72.a(zlib.o):zlib.cpp:(.text+0x214): undefined reference to `deflateEnd'
D:\boost_1_72_0\stage\lib/libboost_iostreams-mgw63-mt-s-x32-1_72.a(zlib.o):zlib.cpp:(.text+0x3c9): undefined reference to `inflateInit2_'
D:\boost_1_72_0\stage\lib/libboost_iostreams-mgw63-mt-s-x32-1_72.a(zlib.o):zlib.cpp:(.text+0x469): undefined reference to `deflateInit2_'
collect2.exe: error: ld returned 1 exit status
makefile:15: recipe for target 'Source.exe' failed
mingw32-make: *** [Source.exe] Error 1
The terminal process terminated with exit code: 1
UPDATE: Also in case the problem may be related to zlib or bz2: I got bz2 lib here: http://gnuwin32.sourceforge.net/packages/bzip2.htm and zlib here: http://gnuwin32.sourceforge.net/packages/zlib.htm And I tried to build zlib myself with their win32 makefile. I got libz.a and tried to build with it as well, nothing's changed.
As you may know, to solve this problem on unix you just need to add -lz
argument.
The same works for windows users. You just (more likely) don't have zlib.a/lib location in your PATH environment variable. So to solve the problem you shall add 2 arguments: -Lpath_to_zlib -lz
. Such a simple solution and I've spent hours trying to fix it.