|
Boost-Build : |
Subject: Re: [Boost-build] Build Boost on WIndows with zlib
From: Paolo Tosco (paolo.tosco_at_[hidden])
Date: 2016-05-15 12:59:05
Dear Steven,
thank you very much for your reply.
On 14/05/2016 02:00, Steven Watanabe wrote:
> AMDG
>
> On 05/12/2016 12:59 PM, Paolo Tosco wrote:
>> Dear all,
>>
>> I have tried to build Boost 1.59.0 on Windows with MSVC 2015 including
>> zlib support for iostreams.
>> While this has never been a problem on Linux, I cannot get the "zlib :
>> yes" message from b2, and I always get both
>> libboost_iostreams-vc140-mt-1_59.lib and
>> libboost_zlib-vc140-mt-1_59.lib, while I should only get the former if
>> zlib had been recognized.
>>
> So, what exactly is the problem? You are
> asking to build zlib from source, and
> it appears to work. The "zlib : yes" is
> not actually printed in this case.
You are right, actually the "zlib : yes" message is only printed when
the -sZLIB_BINARY and -sZLIB_LIBPATH switches are used.
However, even though boost_iostreams has been built with zlib support, I
am unable to link a very simple test program:
#include <boost/iostreams/filter/zlib.hpp>
int main() {
int a = boost::iostreams::zlib::default_compression;
return 0;
}
cl /EHsc /DBOOST_ALL_NO_LIB /MD /I. /IC:\build\zlib-1.2.8 testzlib.cpp
stage\lib\boost_iostreams-vc140-mt-1_59.lib C:\build\zlib-1.2.8\zlib.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23918 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
testzlib.cpp
Microsoft (R) Incremental Linker Version 14.00.23918.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:testzlib.exe
testzlib.obj
stage\lib\boost_iostreams-vc140-mt-1_59.lib
C:\build\zlib-1.2.8\zlib.lib
testzlib.obj : error LNK2019: unresolved external symbol "int const
boost::iostreams::zlib::default_compression"
(?default_compression_at_zlib@iostreams_at_boost@@3HB) referenced in function main
testzlib.exe : fatal error LNK1120: 1 unresolved externals
However, the symbol is correctly exported in the DLL:
dumpbin.exe /EXPORTS stage\lib\boost_iostreams-vc140-mt-1_59.lib | grep
default_compression
?default_compression_at_zlib@iostreams_at_boost@@3HB (int
const boost::iostreams::zlib::default_compression)
The test program builds correctly if I build against the zlib.obj file
rather than against boost_iostreams-vc140-mt-1_59.lib:
cl /EHsc /DBOOST_ALL_NO_LIB /MD /I. /IC:\build\zlib-1.2.8 testzlib.cpp
bin.v2\libs\iostreams\build\msvc-14.0\release\address-model-64\threading-multi\zlib.obj
C:\build\zlib-1.2.8\zlib.lib
I don't have problems in linking the test program against
boost_iostreams on Linux.
I have the impression that the problem is that Windows does not support
exporting global static constants in DLLs.
In fact, if I add the following to zlib.hpp:
BOOST_IOSTREAMS_DECL const int get_default_compression();
and the following to zlib.cpp:
BOOST_IOSTREAMS_DECL const int get_default_compression() {
return default_compression;
}
and I modify the test program as follows:
#include <boost/iostreams/filter/zlib.hpp>
int main() {
int a = boost::iostreams::zlib::get_default_compression();
return 0;
}
it then links fine against boost_iostreams:
cl /EHsc /DBOOST_ALL_NO_LIB /MD /I. /IC:\build\zlib-1.2.8 testzlib.cpp
stage\lib\boost_iostreams-vc140-mt-1_59.lib C:\build\zlib-1.2.8\zlib.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23918 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
testzlib.cpp
Microsoft (R) Incremental Linker Version 14.00.23918.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:testzlib.exe
testzlib.obj
stage\lib\boost_iostreams-vc140-mt-1_59.lib
C:\build\zlib-1.2.8\zlib.lib
Do you have any suggestions how to fix the problem?
I really appreciate your help, and please bear with me if the above is
not clear or if I inadvertently did some silly mistake.
Kind regards,
Paolo
>> This is the command line that I have used:
>>
>> b2 -a -q -j4 address-model=64 link=static threading=multi
>> runtime-link=shared variant=release --with-iostreams
>> -sZLIB_SOURCE="C:/64/boost_1_59_0_py35_build/source/zlib-1.2.8"
>>
>> according to the instructions found in
>>
>> http://lists.boost.org/boost-users/2014/04/81927.php
>>
>> I have also tried to set the environment variable as suggested in
>>
>> http://lists.boost.org/boost-users/2014/04/81894.php
>>
>> but this didn't help either.
>>
>> Could someone tell me what am I doing wrong?
>>
> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk