microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.17k stars 6.39k forks source link

[boost-iostreams] linker failure #32378

Open Werni2A opened 1 year ago

Werni2A commented 1 year ago

Operating system

Linux

Compiler

GCC

Steps to reproduce the behavior

See the `reproduzer.zip` file in the next section where I provide a minimal reproducer.

Failure logs

reproducer.zip

./build.sh 
-- Running vcpkg install
Detecting compiler hash for triplet x64-linux...
The following packages will be built and installed:
  * boost-array:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-array/58b11354551eb994ef8636b3ade5447ae6524a3c
  * boost-assert:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-assert/9ab1404e2abab757e8c136c9fcd89fbca14e3696
  * boost-bind:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-bind/9c07d5ea417668fe7606ace4749f1577c7c2a8c1
  * boost-build:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-build/c9cbed98f75a402e9f61689754e78e237f44988e
  * boost-concept-check:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-concept-check/e3db560953c33956f9ba0b19303f99e37d2c6486
  * boost-config:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-config/b4dcdf4527bb037a6b6d2973176e4a662c9853e6
  * boost-container-hash:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-container-hash/ce9e91e833ca8eb5ddb0a19df8eb7fa5c809359c
  * boost-conversion:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-conversion/42db7c7d2cd967a8602ccbecd50d17ecc45c0f9b
  * boost-core:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-core/fc2d558e972d703d21819dc33f5178d6bf529a22
  * boost-describe:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-describe/57b9e703cb64af9391eb2410ef649a94cb34e4fb
  * boost-detail:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-detail/e6869735032c72f50cd3e5cfdfd08a317fbe1efd
  * boost-dynamic-bitset:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-dynamic-bitset/5ef863abb9f1f4ca201881743fffe4f47930b472
  * boost-function:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-function/9dec477afa8d43d2a95ff257974e703a5fe7835d
  * boost-function-types:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-function-types/bf2f0ad26a4cfe85854392e5579bc75d7a4a60d3
  * boost-functional:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-functional/fd5a2fb579f798abd7b8b0c118543c92ee0f0774
  * boost-fusion:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-fusion/b150ab085d5b818a169fc105e3b096bf7493e5b0
  * boost-integer:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-integer/46935203002bae9d52b70d217abde7758c21d2ba
  * boost-io:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-io/2e824cb312fdf8d4b782b625053595e9bb13dc3c
    boost-iostreams[bzip2,core,lzma,zlib,zstd]:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-iostreams/ac82b98be4e5ba2e754a532ba2754ae4f0496469
  * boost-iterator:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-iterator/32b20eaa8ec0539f484ba8dc1a08fd163757d48d
  * boost-modular-build-helper:x64-linux -> 1.82.0#3 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-modular-build-helper/98f75b07bdab1080c9470eb115836035d7142397
  * boost-move:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-move/bda03863857c818ffb310f45d2d148553a5de381
  * boost-mp11:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-mp11/a90f12d1eca80483d10bbd93deccf5439f904e04
  * boost-mpl:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-mpl/f2d9b906b09ffd6317c9de5f97537688cde482bd
  * boost-numeric-conversion:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-numeric-conversion/00e6f269cd4fab6986205b397e46394795941f31
  * boost-optional:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-optional/26a359b912dd2fb42978ddf8ae39fbbccc1e34bb
  * boost-predef:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-predef/a7efd1a99c14c79b469d86bbf9d39898ffde1858
  * boost-preprocessor:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-preprocessor/11fa54ebde61dcf9ca2e18a42aa7445b76ce9400
  * boost-random:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-random/c440ed1d17008e8a77ff3cdcc495af47103f05be
  * boost-range:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-range/1b034bcdf929c6bc7cfd900580907fd1ca6620fd
  * boost-regex:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-regex/fc3fcb5815c297112283b9fd5eabab3106f6e93e
  * boost-smart-ptr:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-smart-ptr/890abd9cae8fc0c9a3a6f9a6b67a4cfab375a775
  * boost-static-assert:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-static-assert/bb7f6ee1209b0760b458727da129653965e7e98a
  * boost-system:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-system/b1bea82cc5898b04f9f797eb47026b667a03de00
  * boost-throw-exception:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-throw-exception/3416e3ed72a0b469169cc290cafeabafe2bc4859
  * boost-tuple:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-tuple/005084a92857215f3e0db64c3a7a1d1d70c91850
  * boost-type-traits:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-type-traits/16673cfc230fda05b63868f9cbf21d0e0a206b53
  * boost-typeof:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-typeof/3a15a938616612d49b404940a26fbf8f518816d8
  * boost-uninstall:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-uninstall/dcca7487581acb01e55bddd3ec306ff543c24ce6
  * boost-utility:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-utility/353c3edd45cc926548492197f73164d5831728f0
  * boost-variant2:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-variant2/dd3e6bcf37179efe2425ffb104be151a9f1133f8
  * boost-vcpkg-helpers:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-vcpkg-helpers/9a0f2ba2f59ce1040abe835b1e5adcd0a6dbc8af
  * boost-winapi:x64-linux -> 1.82.0#2 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/boost-winapi/4fb732247dac823b0563bd50e4fc518c25eb9334
  * bzip2[core,tool]:x64-linux -> 1.0.8#4 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/bzip2/6165360d15e6de08dff3a5f079d51e69908cc55d
  * liblzma:x64-linux -> 5.4.3 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/liblzma/ba357d6805e44b3df1ed4343801f1b61a5d63de0
  * vcpkg-cmake:x64-linux -> 2023-05-04 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/vcpkg-cmake/88a7058fc7fa73a9c4c99cfcae9d79e2abf87a5a
  * vcpkg-cmake-config:x64-linux -> 2022-02-06#1 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/vcpkg-cmake-config/8d54cc4f487d51b655abec5f9c9c3f86ca83311f
  * vcpkg-cmake-get-vars:x64-linux -> 2023-03-02 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/vcpkg-cmake-get-vars/2e624c2cf12a97a7a802e31ff1d28b9fa6ba9bde
  * zlib:x64-linux -> 1.2.13 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/zlib/ad5a49006f73b45b715299515f31164131b51982
  * zstd:x64-linux -> 1.5.5 -- /home/dom/Desktop/git/vcpkg/buildtrees/versioning_/versions/zstd/2a6d14da5f876e43859950a12a330f8b03cdc327
Additional packages (*) will be modified to complete this operation.
Restored 50 package(s) from /home/dom/.cache/vcpkg/archives in 357 ms. Use --debug to see more details.
Installing 1/50 vcpkg-cmake-config:x64-linux...
Elapsed time to handle vcpkg-cmake-config:x64-linux: 1.11 ms
Installing 2/50 vcpkg-cmake:x64-linux...
Elapsed time to handle vcpkg-cmake:x64-linux: 918 us
Installing 3/50 zstd:x64-linux...
Elapsed time to handle zstd:x64-linux: 1.78 ms
Installing 4/50 zlib:x64-linux...
Elapsed time to handle zlib:x64-linux: 1.39 ms
Installing 5/50 liblzma:x64-linux...
Elapsed time to handle liblzma:x64-linux: 2.11 ms
Installing 6/50 boost-uninstall:x64-linux...
Elapsed time to handle boost-uninstall:x64-linux: 1.05 ms
Installing 7/50 boost-vcpkg-helpers:x64-linux...
Elapsed time to handle boost-vcpkg-helpers:x64-linux: 1.03 ms
Installing 8/50 boost-config:x64-linux...
Elapsed time to handle boost-config:x64-linux: 10.1 ms
Installing 9/50 boost-static-assert:x64-linux...
Elapsed time to handle boost-static-assert:x64-linux: 3.01 ms
Installing 10/50 boost-type-traits:x64-linux...
Elapsed time to handle boost-type-traits:x64-linux: 14.1 ms
Installing 11/50 boost-assert:x64-linux...
Elapsed time to handle boost-assert:x64-linux: 2.64 ms
Installing 12/50 boost-throw-exception:x64-linux...
Elapsed time to handle boost-throw-exception:x64-linux: 2.37 ms
Installing 13/50 boost-preprocessor:x64-linux...
Elapsed time to handle boost-preprocessor:x64-linux: 33.2 ms
Installing 14/50 boost-io:x64-linux...
Elapsed time to handle boost-io:x64-linux: 2.94 ms
Installing 15/50 boost-core:x64-linux...
Elapsed time to handle boost-core:x64-linux: 6.38 ms
Installing 16/50 boost-utility:x64-linux...
Elapsed time to handle boost-utility:x64-linux: 4.43 ms
Installing 17/50 boost-move:x64-linux...
Elapsed time to handle boost-move:x64-linux: 5.51 ms
Installing 18/50 boost-smart-ptr:x64-linux...
Elapsed time to handle boost-smart-ptr:x64-linux: 9.26 ms
Installing 19/50 boost-predef:x64-linux...
Elapsed time to handle boost-predef:x64-linux: 13.2 ms
Installing 20/50 boost-mpl:x64-linux...
Elapsed time to handle boost-mpl:x64-linux: 58.8 ms
Installing 21/50 vcpkg-cmake-get-vars:x64-linux...
Elapsed time to handle vcpkg-cmake-get-vars:x64-linux: 3.75 ms
Installing 22/50 boost-modular-build-helper:x64-linux...
Elapsed time to handle boost-modular-build-helper:x64-linux: 2.92 ms
Installing 23/50 boost-integer:x64-linux...
Elapsed time to handle boost-integer:x64-linux: 3.87 ms
Installing 24/50 boost-mp11:x64-linux...
Elapsed time to handle boost-mp11:x64-linux: 5.06 ms
Installing 25/50 boost-describe:x64-linux...
Elapsed time to handle boost-describe:x64-linux: 5.03 ms
Installing 26/50 boost-container-hash:x64-linux...
Elapsed time to handle boost-container-hash:x64-linux: 4.76 ms
Installing 27/50 boost-concept-check:x64-linux...
Elapsed time to handle boost-concept-check:x64-linux: 5.99 ms
Installing 28/50 boost-build:x64-linux...
Elapsed time to handle boost-build:x64-linux: 60.2 ms
Installing 29/50 boost-regex:x64-linux...
Elapsed time to handle boost-regex:x64-linux: 12.8 ms
Installing 30/50 boost-tuple:x64-linux...
Elapsed time to handle boost-tuple:x64-linux: 4.67 ms
Installing 31/50 boost-detail:x64-linux...
Elapsed time to handle boost-detail:x64-linux: 4.6 ms
Installing 32/50 boost-optional:x64-linux...
Elapsed time to handle boost-optional:x64-linux: 4.59 ms
Installing 33/50 boost-typeof:x64-linux...
Elapsed time to handle boost-typeof:x64-linux: 7.97 ms
Installing 34/50 boost-function-types:x64-linux...
Elapsed time to handle boost-function-types:x64-linux: 11 ms
Installing 35/50 boost-bind:x64-linux...
Elapsed time to handle boost-bind:x64-linux: 7.27 ms
Installing 36/50 boost-function:x64-linux...
Elapsed time to handle boost-function:x64-linux: 6.43 ms
Installing 37/50 boost-functional:x64-linux...
Elapsed time to handle boost-functional:x64-linux: 6.01 ms
Installing 38/50 boost-fusion:x64-linux...
Elapsed time to handle boost-fusion:x64-linux: 69.5 ms
Installing 39/50 boost-conversion:x64-linux...
Elapsed time to handle boost-conversion:x64-linux: 5.52 ms
Installing 40/50 boost-iterator:x64-linux...
Elapsed time to handle boost-iterator:x64-linux: 8.81 ms
Installing 41/50 boost-array:x64-linux...
Elapsed time to handle boost-array:x64-linux: 7.24 ms
Installing 42/50 boost-range:x64-linux...
Elapsed time to handle boost-range:x64-linux: 17.1 ms
Installing 43/50 boost-winapi:x64-linux...
Elapsed time to handle boost-winapi:x64-linux: 15.3 ms
Installing 44/50 boost-variant2:x64-linux...
Elapsed time to handle boost-variant2:x64-linux: 7.92 ms
Installing 45/50 boost-system:x64-linux...
Elapsed time to handle boost-system:x64-linux: 7.62 ms
Installing 46/50 boost-dynamic-bitset:x64-linux...
Elapsed time to handle boost-dynamic-bitset:x64-linux: 6.8 ms
Installing 47/50 boost-random:x64-linux...
Elapsed time to handle boost-random:x64-linux: 12.6 ms
Installing 48/50 boost-numeric-conversion:x64-linux...
Elapsed time to handle boost-numeric-conversion:x64-linux: 17.5 ms
Installing 49/50 bzip2:x64-linux...
Elapsed time to handle bzip2:x64-linux: 9.23 ms
Installing 50/50 boost-iostreams:x64-linux...
Elapsed time to handle boost-iostreams:x64-linux: 14.1 ms
Total install time: 545 ms
The package boost is compatible with built-in CMake targets:

    find_package(Boost REQUIRED [COMPONENTS <libs>...])
    target_link_libraries(main PRIVATE Boost::boost Boost::<lib1> Boost::<lib2> ...)

-- Running vcpkg install - done
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /usr/share/cmake-3.25/Modules/FindBoost.cmake:1384 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake-3.25/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.25/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
  build/vcpkg_installed/x64-linux/share/boost/vcpkg-cmake-wrapper.cmake:11 (_find_package)
  /home/dom/Desktop/git/vcpkg/scripts/buildsystems/vcpkg.cmake:809 (include)
  CMakeLists.txt:8 (find_package)

CMake Warning at /usr/share/cmake-3.25/Modules/FindBoost.cmake:1384 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake-3.25/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.25/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
  build/vcpkg_installed/x64-linux/share/boost/vcpkg-cmake-wrapper.cmake:11 (_find_package)
  /home/dom/Desktop/git/vcpkg/scripts/buildsystems/vcpkg.cmake:809 (include)
  CMakeLists.txt:8 (find_package)

-- Found Boost: /home/dom/Desktop/git/forks/wxInclude/reproducer/build/vcpkg_installed/x64-linux/include (found version "1.82.0") found components: iostreams regex 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dom/Desktop/git/forks/wxInclude/reproducer/build
[ 50%] Building CXX object CMakeFiles/reproducer.dir/main.cpp.o
[100%] Linking CXX executable reproducer
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::do_init(bool, void* (*)(void*, int, int), void (*)(void*, void*), void*)':
/home/dom/Desktop/git/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:156: undefined reference to `BZ2_bzCompressInit'
/usr/bin/ld: /home/dom/Desktop/git/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:160: undefined reference to `BZ2_bzDecompressInit'
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::end(bool, std::nothrow_t)':
/home/dom/Desktop/git/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:119: undefined reference to `BZ2_bzCompressEnd'
/usr/bin/ld: /home/dom/Desktop/git/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:119: undefined reference to `BZ2_bzDecompressEnd'
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::compress(int)':
/home/dom/Desktop/git/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:131: undefined reference to `BZ2_bzCompress'
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::decompress()':
/home/dom/Desktop/git/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:136: undefined reference to `BZ2_bzDecompress'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/reproducer.dir/build.make:99: reproducer] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/reproducer.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

Additional context

Probably a variant/regression of https://github.com/microsoft/vcpkg/issues/22817

Duplicate of https://github.com/microsoft/vcpkg/issues/27938, there it's mentioned that I need to install the bzip2 and/or zlib dependencies. Adding them to vcpkg.json and adding them to CMakeLists.txt solves my issue but shouldn't boost-iostream know about it's own dependencies and pull them in?

Osyotr commented 1 year ago

shouldn't boost-iostream know about it's own dependencies and pull them in?

The port does correctly pull bzip2 and zlib dependencies, so you don't have to add them to your vcpkg.json. The problem is that you link statically and CMake's FindBoost.cmake does not call find_package(BZip2) for you (and it probably just doesn't know whether boost-iostream was build with bzip2 support or not).

Werni2A commented 1 year ago

I see. In the command line output there are a few lines that show how to include the library into my CMake project. For Boost it's:

The package boost is compatible with built-in CMake targets:

    find_package(Boost REQUIRED [COMPONENTS <libs>...])
    target_link_libraries(main PRIVATE Boost::boost Boost::<lib1> Boost::<lib2> ...)

Maybe it's possible to check if boost-iostreams was specified as component and extend the output with the include directives for it's dependencies.

The package boost is compatible with built-in CMake targets:

    find_package(Boost REQUIRED [COMPONENTS <libs>...])
    target_link_libraries(main PRIVATE Boost::boost Boost::<lib1> Boost::<lib2> ...)

Note that `boost-iostream` requires one of or a combination of the targets [bzip2, lzma, zlib, zstd].

The package zstd provides CMake targets:

    find_package(zstd CONFIG REQUIRED)
    target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>)

The package zlib is compatible with built-in CMake targets:

    find_package(ZLIB REQUIRED)
    target_link_libraries(main PRIVATE ZLIB::ZLIB)

liblzma is compatible with built-in CMake targets:

    find_package(LibLZMA REQUIRED)
    target_link_libraries(main PRIVATE LibLZMA::LibLZMA)

liblzma provides CMake targets:

    find_package(liblzma CONFIG REQUIRED)
    target_link_libraries(main PRIVATE liblzma::liblzma)

The package bzip2 is compatible with built-in CMake targets:

    find_package(BZip2 REQUIRED)
    target_link_libraries(main PRIVATE BZip2::BZip2)

Just an idea. Feel free to close this issue.

dg0yt commented 1 year ago

extend the output with the include directives for it's dependencies.

No, the user should not need to do anything else. This must be handled with patches and/or wrappers.

Osyotr commented 1 year ago

No, the user should not need to do anything else. This must be handled with patches and/or wrappers.

IMO this is an upstream issue and must be reported in CMake repo first.

JonLiu1993 commented 1 year ago

@Werni2A, thanks for posting this issue, I followed your steps to reproduce and building boost-iostreams also failed, but I got a different error than yours:

-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: Boost_INCLUDE_DIR iostreams)
Call Stack (most recent call first):
  vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/share/cmake-3.25/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
  vcpkg/scripts/buildsystems/vcpkg.cmake:855 (_find_package)
  CMakeLists.txt:8 (find_package)

-- Configuring incomplete, errors occurred!
Werni2A commented 1 year ago

@JonLiu1993 I tried again with the latest vcpkg version and the attached reproducer where I get the same error report as mentioned above. I have no idea why CMake behaves differently in you case. Our application versions seem pretty much the same:

$ gcc --version
gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0

$ cmake --version
cmake version 3.25.1

$ vcpkg --version
vcpkg package management program version 2023-06-22-f19f3d9939100085fe2f7e41502d60b08e2083b6

$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
JonLiu1993 commented 1 year ago

@Werni2A, thanks for the double confirmation, I git cloned a new vcpkg and following your steps I successfully built boost-iostreams:

test@test001:~/build$ /home/test/vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/bin/cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/test/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DVCPKG_BUILD_TYPE=debug
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: iostreams
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    VCPKG_BUILD_TYPE

-- Build files have been written to: /home/test/build
test@test001:~/build$ ls
CMakeCache.txt  CMakeFiles  Makefile  cmake_install.cmake
test@test001:~/build$ /home/test/vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/bin/cmake --build .
[ 50%] Building CXX object CMakeFiles/reproducer.dir/main.cpp.o
[100%] Linking CXX executable reproducer
[100%] Built target reproducer

The port does correctly pull the bzip2and zlib dependencies.

Osyotr commented 1 year ago

thanks for the double confirmation, I git cloned a new vcpkg and following your steps I successfully built boost-iostreams -DVCPKG_TARGET_TRIPLET=x64-windows -DVCPKG_BUILD_TYPE=debug Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake

What exactly did you do? o_O

Werni2A commented 1 year ago

@JonLiu1993 thanks for trying to reproduce. I'm not sure how you got it working with the -DVCPKG_TARGET_TRIPLET=x64-windows flag. On my Linux machine this fails with error: in triplet x64-windows: Use of Visual Studio's Developer Prompt is unsupported on non-Windows hosts.. Probably you use WSL? Anyway I can't test on Windows or WSL, could therefore be a Linux only issue.

JonLiu1993 commented 1 year ago

@Osyotr @Werni2A , Full steps to reproduce are here:

test@test001:~$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.20)

project(reproducer)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Boost COMPONENTS iostreams REQUIRED)

add_executable(reproducer main.cpp)

target_include_directories(reproducer PRIVATE
                           ${Boost_INCLUDE_DIRS}
)

target_link_libraries(reproducer PRIVATE
                      Boost::boost
                      Boost::iostreams
)
test@test001:~$ cat main.cpp
#include <boost/iostreams/filter/bzip2.hpp>

int main()
{
    boost::iostreams::bzip2_decompressor();
    return 0;
}
test@test001:~$ cat vcpkg/vcpkg.json
{
    "name": "reproducer",
    "version": "0.0.1",
    "dependencies": [
        "boost-iostreams"
    ],
    "builtin-baseline": "64adda19c86e89526b5e27703a193c14477cce07"
  }
test@test001:~$ cd vcpkg/
test@test001:~/vcpkg$ ./vcpkg install
Detecting compiler hash for triplet x64-linux...
All requested packages are currently installed.
Total install time: 600 ns
The package boost is compatible with built-in CMake targets:

    find_package(Boost REQUIRED [COMPONENTS <libs>...])
    target_link_libraries(main PRIVATE Boost::boost Boost::<lib1> Boost::<lib2> ...)

test@test001:~/vcpkg$ cd ../build/
test@test001:~/build$ /home/test/vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/bin/cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/test/vcpkg/scripts/buildsystems/vcpkg.cmake
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: iostreams
-- Configuring done
-- Generating done
-- Build files have been written to: /home/test/build
test@test001:~/build$ /home/test/vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/bin/cmake --build .
[ 50%] Building CXX object CMakeFiles/reproducer.dir/main.cpp.o
[100%] Linking CXX executable reproducer
[100%] Built target reproducer
dg0yt commented 1 year ago

-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: iostreams

Still not finding vcpkg boost.

github-actions[bot] commented 10 months ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

github-actions[bot] commented 4 months ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

dg0yt commented 3 months ago

Can it be reproduced now when vcpkg builds boost with CMake?

JonLiu1993 commented 2 weeks ago

Can it be reproduced now when vcpkg builds boost with CMake?

This error can still be reproduced:

test@docker:~/Jon$ ./build.sh
-- Running vcpkg install
-- Running vcpkg install - done
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /usr/share/cmake-3.16/Modules/FindBoost.cmake:1161 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindBoost.cmake:1283 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.16/Modules/FindBoost.cmake:1921 (_Boost_MISSING_DEPENDENCIES)
  build/vcpkg_installed/x64-linux/share/boost/vcpkg-cmake-wrapper.cmake:11 (_find_package)
  vcpkg/scripts/buildsystems/vcpkg.cmake:813 (include)
  CMakeLists.txt:8 (find_package)

CMake Warning at /usr/share/cmake-3.16/Modules/FindBoost.cmake:1161 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindBoost.cmake:1283 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.16/Modules/FindBoost.cmake:1921 (_Boost_MISSING_DEPENDENCIES)
  build/vcpkg_installed/x64-linux/share/boost/vcpkg-cmake-wrapper.cmake:11 (_find_package)
  vcpkg/scripts/buildsystems/vcpkg.cmake:813 (include)
  CMakeLists.txt:8 (find_package)

-- Found Boost: /home/test/Jon/build/vcpkg_installed/x64-linux/include (found version "1.82.0") found components: iostreams regex
-- Configuring done
-- Generating done
-- Build files have been written to: /home/test/Jon/build
Scanning dependencies of target reproducer
[ 50%] Building CXX object CMakeFiles/reproducer.dir/main.cpp.o
[100%] Linking CXX executable reproducer
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::do_init(bool, void* (*)(void*, int, int), void (*)(void*, void*), void*)':
/home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:156: undefined reference to `BZ2_bzCompressInit'
/usr/bin/ld: /home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:160: undefined reference to `BZ2_bzDecompressInit'
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::end(bool, std::nothrow_t)':
/home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:119: undefined reference to `BZ2_bzCompressEnd'
/usr/bin/ld: /home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:119: undefined reference to `BZ2_bzDecompressEnd'
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::compress(int)':
/home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:131: undefined reference to `BZ2_bzCompress'
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::decompress()':
/home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:136: undefined reference to `BZ2_bzDecompress'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/reproducer.dir/build.make:86: reproducer] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/reproducer.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Osyotr commented 2 weeks ago

This error can still be reproduced

Try with boost's cmake config. It does have required add_dependency and target_link_libraries calls.