Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[package] boost/1.74.0: won't link #5156

Closed
bahlborn opened this issue Apr 8, 2021 · 11 comments
Closed

[package] boost/1.74.0: won't link #5156

bahlborn opened this issue Apr 8, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@bahlborn
Copy link

bahlborn commented Apr 8, 2021

Package and Environment Details (include every applicable attribute)

  • Package Name/Version: boost/1.74.0
  • Operating System+version: Windows 10 Pro 10.0.19042 Build 19042
  • Compiler+version: MSVC 2019 version 16.9.1
  • Conan version: conan 1.35.0
  • Python version: Python 3.9.1

Conan profile (output of conan profile show default or conan profile show <profile> if custom profile is in use)

[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
build_type=Release
[options]
[build_requires]
[env]

Steps to reproduce (Include if Applicable)

Using cmake_find_package generator and cmake find_package(Boost), the following error happens when linking:
LNK1104 cannot open file 'libboost_filesystem-vc142-mt-sgd-x64-1_74.lib'

@bahlborn bahlborn added the bug Something isn't working label Apr 8, 2021
@Nekto89
Copy link
Contributor

Nekto89 commented Apr 8, 2021

Are you using "Boost::disable_autolinking"?

@bahlborn
Copy link
Author

bahlborn commented Apr 8, 2021 via email

@bahlborn
Copy link
Author

bahlborn commented Apr 8, 2021 via email

@helmesjo
Copy link

helmesjo commented Apr 15, 2021

@Nekto89 Any ideas for this? Basically when "linking" the headers-only target Boost::headers it appears to still include actual targets to link (and the wrong lib-names: libboost_filesystem-vc142-mt-sgd-x64-1_74.lib instead of the correct libboost_filesystem.lib), not only headers/include paths.
@madebr Since you did #2097 (which worked in this case when it was first merged), do you spot any oddities in recent changes? Since one doesn't necessarily clear the cache every day it's hard to tell when this started happening (and what commit that's possibly the culprit).

@madebr
Copy link
Contributor

madebr commented Apr 15, 2021

@helmesjo

The "Disabled magic autolinking (smart and magic decisions)" message is emitted here:

if self._is_msvc or self._is_clang_cl:
if self.options.magic_autolink:
if self.options.layout == "system":
self.cpp_info.components["_libboost"].defines.append("BOOST_AUTO_LINK_SYSTEM")
elif self.options.layout == "tagged":
self.cpp_info.components["_libboost"].defines.append("BOOST_AUTO_LINK_TAGGED")
self.output.info("Enabled magic autolinking (smart and magic decisions)")
else:
# DISABLES AUTO LINKING! NO SMART AND MAGIC DECISIONS THANKS!
self.cpp_info.components["disable_autolinking"].defines = ["BOOST_ALL_NO_LIB"]
self.output.info("Disabled magic autolinking (smart and magic decisions)")

Try adding add_definitions(BOOST_ALL_NO_LIB) to the top of your cmake build script (after project).
It that works, then somehow the incorrect compile flags are passed to the compiler.

See https://www.boost.org/doc/libs/1_75_0/libs/config/doc/html/index.html#boost_config.configuring_boost_for_your_platform.user_settable_options for the available definitions.

@helmesjo
Copy link

helmesjo commented Apr 15, 2021

@madebr With add_definitions(-DBOOST_ALL_NO_LIB) it doesn't fail on the missing lib so I guess your hypothesis is correct.
But now instead I get unresolved symbols pointing to boost::filesystem so it appears some header we use is still calling functions from that lib.

@madebr
Copy link
Contributor

madebr commented Apr 15, 2021

All cmake targets that use boost's filesystem or are exposing boost filesystem through its headers must link to Boost::filesystem.
See https://cmake.org/cmake/help/latest/module/FindBoost.html#imported-targets for the available targets.

@helmesjo
Copy link

Thanks! Yeah, had to dig through the includes in boost/process to see that it reaches into filesystem (even though the error already suggested this), but it was hard to figure this one out since the documentation doesn't appear to explicitly say it (or I'm just poor at googling).

So basically Boost::process is a header-only lib that requires other non-header-only libs..? Linking Boost::headers & Boost::filesystem appears to be enough.

Now there is just the problem that linking only Boost::headers tricks CMake into automagically link non-existing libraries (wrong naming convention) I guess (but yes I can get around that for now by explicitly linking both headers & filesystem).

@madebr
Copy link
Contributor

madebr commented Apr 15, 2021

The current conanfile only passes these definitions (BOOST_ALL_NO_LIB) for the library components, not for the header component.
Maybe we should change this to add these defines to the header component.

Soon, boost 1.75.0 will be released.
I'll try to shove in this change.

@madebr
Copy link
Contributor

madebr commented Apr 17, 2021

I am now going through the boost recipe to add 1.76.0.
I will not make the change I suggested in my previous comment
The FindBoost document suggests to use Boost::disable_autolinking to "disable automatic linking with MSVC (adds -DBOOST_ALL_NO_LIB)".

@SSE4
Copy link
Contributor

SSE4 commented Sep 26, 2021

need to link with Boost::disable_autolinking in order to disable auto-linking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants