question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[package] boost/1.72.0: dependency 'b2' not found when cross compiling

See original GitHub issue

Summary

When cross compiling boost the conan build system does not find the build_requires dependency b2. b2 does get built with the correct compiler and works but the boost recipe can not access the dependency - specifically, the key b2 does not exist in self.deps_cpp_info and the compilation process aborts with this error message:

ERROR: boost/1.72.0: Error in build() method, line 408
	full_command = "%s %s" % (self._b2_exe, b2_flags)
while calling '_b2_exe', line 340
	return os.path.join(self.deps_cpp_info["b2"].rootpath, "bin", b2_exe)
	KeyError: 'b2'

This has been tested with two different cross toolchains for different target systems.

Package and Environment Details

  • Package Name/Version: boost/1.72.0
  • Operating System+version: Linux Ubuntu 19.10
  • ‘build’ context compiler: gcc 9.2.1
  • ‘host’ context compilers: x86_64-w64-mingw32-gcc 9.2-win32 and x86_64-apple-darwin19-clang 9.0.0-2 (from https://github.com/tpoechtrager/osxcross)
  • Conan version: conan 1.24.0
  • Python version: Python 3.7.5

Conan profiles

Configuration for profile default (the build profile):

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=9.2
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]

Configuration for profile x86_64-w64-mingw32 (one of the tested host profiles):

[settings]
os=Windows
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=9.2
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
CC=x86_64-w64-mingw32-gcc
CXX=x86_64-w64-mingw32-g++

Configuration for profile x86_64-apple-darwin19 (one of the tested host profiles):

[settings]
os=Macos
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=9
compiler.libcxx=libc++
build_type=Release
[options]
[build_requires]
[env]
CC=x86_64-apple-darwin19-clang
CXX=x86_64-apple-darwin19-clang++
SDKROOT=/opt/osxcross/SDK/MacOSX10.15.sdk

Steps to reproduce

  • Install conan-1.24.0 and above profiles.

  • Create a simple conanfile.txt in an otherwise empty directory:

[generators]
cmake

[requires]
boost/1.72.0
  • Build and install boost with the following command:
conan install . --profile:host x86_64-w64-mingw32 --profile:build default --build

Logs

boost-build.log conan_trace.log conanfile.txt

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jgsogocommented, Apr 13, 2020

Hi! It is great to know that someone is experimenting with the new cross building model, receiving feedback about this kind of features in real scenarios is very important for us 🙌

Using the new approach with the host and build profiles, it changes a little bit how things are propagated to consumers. Important bits here (we are interested in the else branch):

if not using_build_profile:  # Do not touch anything
    conan_file.deps_user_info[n.ref.name] = n.conanfile.user_info
    conan_file.deps_cpp_info.update(n.conanfile._conan_dep_cpp_info, n.ref.name)
    conan_file.deps_env_info.update(n.conanfile.env_info, n.ref.name)
else:
    if n in transitive or n in br_host:
        conan_file.deps_cpp_info.update(n.conanfile._conan_dep_cpp_info, n.ref.name)
    else:
        env_info = EnvInfo()
        env_info._values_ = n.conanfile.env_info._values_.copy()
        # Add cpp_info.bin_paths/lib_paths to env_info (it is needed for runtime)
        env_info.DYLD_LIBRARY_PATH.extend(n.conanfile._conan_dep_cpp_info.lib_paths)
        env_info.DYLD_LIBRARY_PATH.extend(n.conanfile._conan_dep_cpp_info.framework_paths)
        env_info.LD_LIBRARY_PATH.extend(n.conanfile._conan_dep_cpp_info.lib_paths)
        env_info.PATH.extend(n.conanfile._conan_dep_cpp_info.bin_paths)
        conan_file.deps_env_info.update(env_info, n.ref.name)

Only requires and build_requires from the host context are propagated to the deps_cpp_info object (it contains compiler flags, libraries to link,… ) and information from the build_requires (build context) is available only as environment, so you can run these applications, but they are not supposed to be linked.


Back to ConanCenter: right now we don’t have a dedicated effort to migrate all the recipes in ConanCenter to the new model because we need feedback about the feature, maybe we have broken something and we don’t know yet… although I’m starting to feel more comfortable about it, it’s been out for a month and a half now and there aren’t issues related to it 😃

The boost recipe in the new model should have just a

self.run("b2 ....", run_environment=True)

and the executable should be in the path. Right now, we can add some if/else to the recipe, or maybe use the tools.which to know if b2 is available in the PATH.


Notes.-

  • We cannot know if b2 is coming from build_requires or it is already installed in the system. Is it important? Can we do it somehow?
  • tools.which(), should it take a run_environment argument?
1reaction
mheysecommented, Apr 9, 2020

The attached boost-build.log was missing the stderr output, here a complete version. boost-build.log

Read more comments on GitHub >

github_iconTop Results From Across the Web

g++ does not find cross compiled boost headers
# First install some dependencies apt-get install -y libflann-dev:armhf libeigen3-dev:armhf libglu1-mesa-dev:armhf freeglut3-dev:armhf mesa- ...
Read more >
Version 1.72.0 - Boost C++ Libraries
Added missing async_initiate to the Windows-specific I/O objects' asynchronous operations. Ensured that the executor type is propagated to newly ...
Read more >
Cross-Compilation of Dependencies - Vanetza
This document summarises a few hints for cross-compiling Vanetza's dependencies. Please note, that cross-compiling is not relevant for you if you plan to...
Read more >
Compare Packages Between Distributions - DistroWatch.com
A complete package list for further comparison is available. Package, Gentoo Linux unstable, Devuan GNU+Linux unstable ceres. abiword (3.0.5), 3.0 ...
Read more >
Details of dev-lang/R - Gentoo Linux Howtos
447396, Server, xmw, UNCONFIRMED, app-admin/bcfg2-1.2.3: missing RDEPEND on ... UNCONFIRMED, sys-devel/llvm fails to cross compile, 2012-11-13 16:20:28.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found