ContinuumIO / anaconda-issues

Anaconda issue tracking
646 stars 220 forks source link

cannot link to boost on Windows #8854

Open 183amir opened 6 years ago

183amir commented 6 years ago

Actual Behavior

I am trying to compile a C++ project that links to boost (system, iostreams, and filesystem) but it fails in the linking stage with the following error:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\Amir\Documents\bob\src\bob.core\build\lib.win-amd64-3.6\bob\core /LIBPATH:C:\Users\Amir\Conda\envs\bob\Library\lib /LIBPATH:C:\Users\Amir\Conda\envs\bob\libs /LIBPATH:C:\Users\Amir\Conda\envs\bob\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" bob_core.lib boost_system-vc140-mt-1_65_1.lib boost_iostreams-vc140-mt-1_65_1.lib boost_filesystem-vc140-mt-1_65_1.lib blitz.lib /EXPORT:PyInit__logging build\temp.win-amd64-3.6\Release\bob/core/logging.obj /OUT:build\lib.win-amd64-3.6\bob\core\_logging.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\bob/core\_logging.cp36-win_amd64.lib
LINK : fatal error LNK1104: cannot open file 'libboost_zlib-vc140-mt-1_65_1.lib'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1104

I have checked and this libboost_zlib....lib file does not exist while other similar boost libraries exist. It's not included in my link command either but the linker complains about it.

Expected Behavior

Either this file should be available or there should be a way to link to to boost_iostreams without getting this error.

Steps to Reproduce

This is the list of boost packages that I am using:

# packages in environment at C:\Users\Amir\Conda\envs\bob:
#
# Name                    Version                   Build  Channel
boost                     1.65.1                   py36_4
libboost                  1.65.1               he51fdeb_4
py-boost                  1.65.1           py36h6538335_4

To reproduce (on a windows machine): Create an environment with this environment file:

name: bob
channels:
  - defaults
  - conda-forge
  - msys2
dependencies:
  - cmake=3.10.0=4
  - libblitz=0.10=vc14_2
  - zlib=1.2.11=vc14_0
  - alabaster=0.7.10=py36hcd07829_0
  - babel=2.5.3=py36_0
  - boost=1.65.1=py36_4
  - certifi=2018.1.18=py36_0
  - click=6.7=py36hec8c647_0
  - click-plugins=1.0.3=py36_0
  - colorama=0.3.9=py36h029ae33_0
  - coverage=4.5.1=py36hfa6e2cd_0
  - decorator=4.2.1=py36_0
  - docutils=0.14=py36h6012d8f_0
  - icc_rt=2017.0.4=h97af966_0
  - imagesize=1.0.0=py36_0
  - intel-openmp=2018.0.0=hd92c6cd_8
  - ipython=6.2.1=py36h9cf0123_1
  - ipython_genutils=0.2.0=py36h3c5d0ee_0
  - jedi=0.11.1=py36_0
  - jinja2=2.10=py36h292fed1_0
  - libboost=1.65.1=he51fdeb_4
  - markupsafe=1.0=py36h0e26971_1
  - mkl=2018.0.1=h2108138_4
  - nose=1.3.7=py36h1c3779e_2
  - numpy=1.14.1=py36h4a99626_1
  - packaging=16.8=py36ha0986f6_1
  - parso=0.1.1=py36hae3edee_0
  - pickleshare=0.7.4=py36h9de030f_0
  - pip=9.0.1=py36_5
  - prompt_toolkit=1.0.15=py36h60b8f86_0
  - py-boost=1.65.1=py36h6538335_4
  - pygments=2.2.0=py36hb010967_0
  - pyparsing=2.2.0=py36h785a196_1
  - python=3.6.4=h6538335_1
  - pytz=2018.3=py36_0
  - requests=2.14.2=py36_0
  - setuptools=38.5.1=py36_0
  - simplegeneric=0.8.1=py36_2
  - six=1.11.0=py36h4db2310_1
  - snowballstemmer=1.2.1=py36h763602f_0
  - sphinx=1.7.1=py36_0
  - sphinx_rtd_theme=0.2.4=py36_0
  - sphinxcontrib=1.0=py36hbbac3d2_1
  - sphinxcontrib-websupport=1.0.1=py36hb5e5916_1
  - traitlets=4.3.2=py36h096827d_0
  - typing=3.6.4=py36_0
  - vc=14=h0510ff6_3
  - vs2015_runtime=14.0.25123=3
  - wcwidth=0.1.7=py36h3d5aa90_0
  - wheel=0.30.0=py36h6c3ec14_1
  - wincertstore=0.2=py36h7fe50ca_0
  - m2w64-libwinpthread-git=5.0.0.4634.697f757=2
  - m2w64-pkg-config=0.29.1=2
  - msys2-conda-epoch=20160418=1

Activate the environment and run:

# develop bob.extension
$ git clone https://github.com/AliKhoda/bob.extension.git
$ cd bob.extension
$ python setup.py develop
$ cd ..
# develop bob.blitz
$ git clone https://github.com/AliKhoda/bob.blitz.git
$ cd bob.blitz
$ python setup.py develop
$ cd ..
# develop bob.core to see the error
$ git clone https://github.com/bioidiap/bob.core.git
$ cd bob.core
$ python setup.py develop
# error will show up
Anaconda or Miniconda version:
Operating System:

Windows 10

conda info
     active environment : bob
    active env location : C:\Users\Amir\Conda\envs\bob
            shell level : 2
       user config file : C:\Users\Amir\.condarc
 populated config files :
          conda version : 4.4.11
    conda-build version : 3.6.0
         python version : 3.6.4.final.0
       base environment : C:\Users\Amir\Conda  (writable)
           channel URLs : https://repo.continuum.io/pkgs/main/win-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/win-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/win-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/win-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://repo.continuum.io/pkgs/msys2/win-64
                          https://repo.continuum.io/pkgs/msys2/noarch
          package cache : C:\Users\Amir\Conda\pkgs
                          C:\Users\Amir\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\Amir\Conda\envs
                          C:\Users\Amir\AppData\Local\conda\conda\envs
                          C:\Users\Amir\.conda\envs
               platform : win-64
             user-agent : conda/4.4.11 requests/2.18.4 CPython/3.6.4 Windows/10 Windows/10.0.16299
          administrator : False
             netrc file : None
           offline mode : False
conda list --show-channel-urls
# packages in environment at C:\Users\Amir\Conda\envs\bob:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.10           py36hcd07829_0    defaults
babel                     2.5.3                    py36_0    defaults
bob.blitz                 2.0.15b0                  <pip>
bob.extension             2.4.6b0                   <pip>
boost                     1.65.1                   py36_4    defaults
certifi                   2018.1.18                py36_0    defaults
click                     6.7              py36hec8c647_0    defaults
click-plugins             1.0.3                    py36_0    defaults
cmake                     3.10.0                        4    conda-forge
colorama                  0.3.9            py36h029ae33_0    defaults
coverage                  4.5.1            py36hfa6e2cd_0    defaults
decorator                 4.2.1                    py36_0    defaults
docutils                  0.14             py36h6012d8f_0    defaults
icc_rt                    2017.0.4             h97af966_0    defaults
imagesize                 1.0.0                    py36_0    defaults
intel-openmp              2018.0.0             hd92c6cd_8    defaults
ipython                   6.2.1            py36h9cf0123_1    defaults
ipython_genutils          0.2.0            py36h3c5d0ee_0    defaults
jedi                      0.11.1                   py36_0    defaults
jinja2                    2.10             py36h292fed1_0    defaults
libblitz                  0.10                     vc14_2  [vc14]  conda-forge
libboost                  1.65.1               he51fdeb_4    defaults
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    msys2
m2w64-pkg-config          0.29.1                        2    msys2
markupsafe                1.0              py36h0e26971_1    defaults
mkl                       2018.0.1             h2108138_4    defaults
msys2-conda-epoch         20160418                      1    msys2
nose                      1.3.7            py36h1c3779e_2    defaults
numpy                     1.14.1           py36h4a99626_1    defaults
packaging                 16.8             py36ha0986f6_1    defaults
parso                     0.1.1            py36hae3edee_0    defaults
pickleshare               0.7.4            py36h9de030f_0    defaults
pip                       9.0.1                    py36_5    defaults
prompt_toolkit            1.0.15           py36h60b8f86_0    defaults
py-boost                  1.65.1           py36h6538335_4    defaults
pygments                  2.2.0            py36hb010967_0    defaults
pyparsing                 2.2.0            py36h785a196_1    defaults
python                    3.6.4                h6538335_1    defaults
pytz                      2018.3                   py36_0    defaults
requests                  2.14.2                   py36_0    defaults
setuptools                38.5.1                   py36_0    defaults
simplegeneric             0.8.1                    py36_2    defaults
six                       1.11.0           py36h4db2310_1    defaults
snowballstemmer           1.2.1            py36h763602f_0    defaults
sphinx                    1.7.1                    py36_0    defaults
sphinx_rtd_theme          0.2.4                    py36_0    defaults
sphinxcontrib             1.0              py36hbbac3d2_1    defaults
sphinxcontrib-websupport  1.0.1            py36hb5e5916_1    defaults
traitlets                 4.3.2            py36h096827d_0    defaults
typing                    3.6.4                    py36_0    defaults
vc                        14                   h0510ff6_3    defaults
vs2015_runtime            14.0.25123                    3    defaults
wcwidth                   0.1.7            py36h3d5aa90_0    defaults
wheel                     0.30.0           py36h6c3ec14_1    defaults
wincertstore              0.2              py36h7fe50ca_0    defaults
zlib                      1.2.11                   vc14_0  [vc14]  conda-forge

And here is the full compile log:

bob.core>python setup.py develop
running develop
running egg_info
writing bob.core.egg-info\PKG-INFO
writing dependency_links to bob.core.egg-info\dependency_links.txt
writing requirements to bob.core.egg-info\requires.txt
writing top-level names to bob.core.egg-info\top_level.txt
reading manifest file 'bob.core.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'bob.core.egg-info\SOURCES.txt'
running build_ext
Re-run cmake no build system arguments
-- Selecting Windows SDK version  to target Windows 10.0.16299.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Amir/Documents/bob/src/bob.core/build/build_cmake/bob_core
Calling the command: ['cmake', '--build', '.', '--target', 'ALL_BUILD', '--config', 'Release']
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 13/03/2018 17:23:49.
Project "C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\ALL_BUILD.vcxproj" on node 1 (default targets).
Project "C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\ALL_BUILD.vcxproj" (1) is building "C:\Users\Amir\Documents\bob
\src\bob.core\build\build_cmake\bob_core\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
InitializeBuildStatus:
  Creating "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
  All outputs are up-to-date.
FinalizeBuildStatus:
  Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
  Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
Done Building Project "C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\ZERO_CHECK.vcxproj" (default targets).

Project "C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\ALL_BUILD.vcxproj" (1) is building "C:\Users\Amir\Documents\bob
\src\bob.core\build\build_cmake\bob_core\bob_core.vcxproj" (3) on node 1 (default targets).
InitializeBuildStatus:
  Creating "bob_core.dir\Release\bob_core.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
  All outputs are up-to-date.
ClCompile:
  All outputs are up-to-date.
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /IC:\Users\Amir\Documents\bob\src\bob.core\bob\core\include
   /Ic:\users\amir\documents\bob\src\bob.blitz\bob\blitz\include /I"C:\Users\Amir\Conda\envs\bob\lib\site-packages\numpy\core\include" /IC:\
  Users\Amir\Conda\envs\bob\Library\include /nologo /W1 /WX- /O2 /Ob2 /D _WIN32_WINNT=0x501 /D NDEBUG /D PY_ARRAY_UNIQUE_SYMBOL=BOB_NUMPY_C_
  API /D NO_IMPORT_ARRAY=1 /D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION /D HAVE_BLITZ=1 /D "BLITZ_VERSION=\"0.10\"" /D "CMAKE_INTDIR=\"Relea
  se\"" /D _MBCS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"bob_core.dir\Release\\" /Fd"bob_core.dir\Release\bob
  _core.pdb" /Gd /TP /errorReport:queue  -Qunused-arguments -O3 -g0 -mtune=native C:\Users\Amir\Documents\bob\src\bob.core\bob\core\cpp\logg
  ing.cpp
cl : Command line warning D9002: ignoring unknown option '-Qunused-arguments' [C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bo
b_core\bob_core.vcxproj]
  logging.cpp
cl : Command line warning D9002: ignoring unknown option '-O3' [C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\bob_core
.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-g0' [C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\bob_core
.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-mtune=native' [C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_cor
e\bob_core.vcxproj]
Lib:
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\Lib.exe /OUT:"C:\Users\Amir\Documents\bob\src\bob.core\build\build_cm
  ake\bob_core\Release\bob_core.lib" /NOLOGO /MACHINE:X64  /machine:x64 bob_core.dir\Release\logging.obj
  bob_core.vcxproj -> C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\Release\bob_core.lib
FinalizeBuildStatus:
  Deleting file "bob_core.dir\Release\bob_core.tlog\unsuccessfulbuild".
  Touching "bob_core.dir\Release\bob_core.tlog\bob_core.lastbuildstate".
Done Building Project "C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\bob_core.vcxproj" (default targets).

InitializeBuildStatus:
  Creating "x64\Release\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
  All outputs are up-to-date.
FinalizeBuildStatus:
  Deleting file "x64\Release\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild".
  Touching "x64\Release\ALL_BUILD\ALL_BUILD.tlog\ALL_BUILD.lastbuildstate".
Done Building Project "C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\ALL_BUILD.vcxproj" (default targets).

Build succeeded.

"C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\bob_core.vcxproj" (default target) (3) ->
(ClCompile target) ->
  cl : Command line warning D9002: ignoring unknown option '-Qunused-arguments' [C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\
bob_core\bob_core.vcxproj]
  cl : Command line warning D9002: ignoring unknown option '-O3' [C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\bob_co
re.vcxproj]
  cl : Command line warning D9002: ignoring unknown option '-g0' [C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_core\bob_co
re.vcxproj]
  cl : Command line warning D9002: ignoring unknown option '-mtune=native' [C:\Users\Amir\Documents\bob\src\bob.core\build\build_cmake\bob_c
ore\bob_core.vcxproj]

    4 Warning(s)
    0 Error(s)

Time Elapsed 00:00:14.65
building 'bob.core._logging' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DBOB_EXT_MODULE_PREFIX=\"bob.core\" -DBOB_EXT_MODULE_NAME=\"_logging\" -DBOB_EXT_ENTRY_NAME=PyInit__logging -DBOB_EXT_MODULE_VERSION=\"2.1.10b0\" -DHAVE_BOOST=1 -DBOOST_VERSION=\"1.65.1\" -DHAVE_BLITZ=1 -DBLITZ_VERSION=\"0.10\" -DPY_ARRAY_UNIQUE_SYMBOL=BOB_NUMPY_C_API -DNO_IMPORT_ARRAY=1 -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -IC:\Users\Amir\Documents\bob\src\bob.core\bob\core\include -Ic:\users\amir\documents\bob\src\bob.blitz\bob\blitz\include -Ic:\users\amir\documents\bob\src\bob.extension\bob\extension\include -IC:\Users\Amir\Conda\envs\bob\include -IC:\Users\Amir\Conda\envs\bob\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /EHsc /Tpbob/core/logging.cpp /Fobuild\temp.win-amd64-3.6\Release\bob/core/logging.obj -std=c++0x -pthread -IC:\Users\Amir\Conda\envs\bob\lib\site-packages\numpy\core\include -IC:\Users\Amir\Conda\envs\bob\Library\include -IC:/Users/Amir/Conda/envs/bob/Library/include
cl : Command line warning D9002 : ignoring unknown option '-std=c++0x'
cl : Command line warning D9002 : ignoring unknown option '-pthread'
logging.cpp
C:\Users\Amir\Conda\envs\bob\Library\include\boost/version.hpp(22): warning C4005: 'BOOST_VERSION': macro redefinition
C:\Users\Amir\Conda\envs\bob\Library\include\boost/version.hpp(22): note: command-line arguments:  see previous definition of 'BOOST_VERSION'
c:\users\amir\documents\bob\src\bob.extension\bob\extension\include\bob.extension/documentation.h(313): warning C4267: 'initializing': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\amir\documents\bob\src\bob.extension\bob\extension\include\bob.extension/documentation.h(357): warning C4267: '+=': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\amir\documents\bob\src\bob.extension\bob\extension\include\bob.extension/documentation.h(361): warning C4267: '+=': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\amir\documents\bob\src\bob.extension\bob\extension\include\bob.extension/documentation.h(379): warning C4267: '+=': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\amir\documents\bob\src\bob.extension\bob\extension\include\bob.extension/documentation.h(498): warning C4267: 'initializing': conversion from 'size_t' to 'unsigned int', possible loss of data
c:\users\amir\documents\bob\src\bob.extension\bob\extension\include\bob.extension/documentation.h(512): warning C4267: 'initializing': conversion from 'size_t' to 'unsigned int', possible loss of data
bob/core/logging.cpp(150): warning C4244: 'initializing': conversion from 'std::streamsize' to 'int', possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\Amir\Documents\bob\src\bob.core\build\lib.win-amd64-3.6\bob\core /LIBPATH:C:\Users\Amir\Conda\envs\bob\Library\lib /LIBPATH:C:\Users\Amir\Conda\envs\bob\libs /LIBPATH:C:\Users\Amir\Conda\envs\bob\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" bob_core.lib boost_system-vc140-mt-1_65_1.lib boost_iostreams-vc140-mt-1_65_1.lib boost_filesystem-vc140-mt-1_65_1.lib blitz.lib /EXPORT:PyInit__logging build\temp.win-amd64-3.6\Release\bob/core/logging.obj /OUT:build\lib.win-amd64-3.6\bob\core\_logging.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\bob/core\_logging.cp36-win_amd64.lib
LINK : fatal error LNK1104: cannot open file 'libboost_zlib-vc140-mt-1_65_1.lib'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1104

ping @alikhoda

benmwebb commented 6 years ago

The workaround I've used in the past is to add /DBOOST_ZLIB_BINARY=kernel32 to the compiler options. This isn't really an Anaconda issue but an issue with the Boost autolinker, which doesn't handle all the ways boost::iostreams can be built with zlib support.

That being said, it looks like the latest Anaconda boost package (1.65.1_4) is lacking support for zlib entirely so you'll just unresolved symbols instead (I'll open a separate issue for this). The latest version that works for me is 1.61.0_0.