Skip to content

Failed to build with libc++(with minimal example to reproduce) #742

@t0ny-peng

Description

@t0ny-peng

Hi there. I'm trying to build a project with g++ coming from GNU and libc++ coming from LLVM as the std library. However the compilation failed on yaml_cpp with some weird error message. Could you please take a look at it and maybe give me some hint of how to solve it?

My GCC version is 7.4.0, which is shipped with Ubuntu Bionic. And the libc++ version is 6.0-2. The yaml_cpp commit is 968e0c1

Here's my minimal example to reproduce the error.

  1. Install libc++
    $ sudo apt install libc++-dev libc++abi-dev
  2. Checkout my fork.
    $ git clone https://github.com/left4taco/yaml-cpp
  3. Build with cmake
    (Note that I added some warning flags in the gcc_flags.cmake, as well as the command to build with libc++
    $ mkdir build
    $ cd build
    $ cmake \
        -DCMAKE_C_FLAGS=-w \
        -DCMAKE_TOOLCHAIN_FILE=gcc_flags.cmake \
        -DBUILD_SHARED_LIBS=ON \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DCMAKE_CXX_COMPILER=/usr/bin/c++ \
        -DCMAKE_CXX_FLAGS=-nostdinc++ \
        -DCMAKE_C_COMPILER=/usr/bin/cc \
        -DCMAKE_C_FLAGS=-w \
        -DYAML_CPP_BUILD_CONTRIB=OFF \
        -DYAML_CPP_BUILD_TESTS=OFF \
        -DYAML_CPP_BUILD_TOOLS=OFF \
        ..
    $ make
  4. It prints whole bunch of errors(see here https://gist.github.com/left4taco/cec0c74ee189bcc94605a35a55049200), like
    In file included from /usr/include/c++/v1/algorithm:642:0,
                     from /home/myname/yaml_cpp/src/convert.cpp:1:
    /usr/include/c++/v1/utility: In instantiation of ‘static constexpr bool std::__1::pair<_T1, _T2>::_CheckArgs::__enable_implicit() [with _U1 = const YAML::Node&; _U2 = const YAML::Node&; _T1 = YAML::Node; _T2 = YAML::Node]’:
    /usr/include/c++/v1/utility:447:75:   required by substitution of ‘template<class _U1, class _U2, typename std::__1::enable_if<__enable_implicit<const _U1&, const _U2&>(), bool>::type <anonymous> > constexpr std::__1::pair<YAML::Node, YAML::Node>::pair(const std::__1::pair<_T1, _T2>&) [with _U1 = YAML::Node; _U2 = YAML::Node; typename std::__1::enable_if<__enable_implicit<const _U1&, const _U2&>(), bool>::type <anonymous> = <missing>]’
    /usr/include/c++/v1/type_traits:3087:54:   required by substitution of ‘template<class _Tp, class _A0, class> static std::__1::is_destructible<_Tp> std::__1::__is_constructible_helper::__test_unary(int) [with _Tp = YAML::Node; _A0 = const YAML::Node&; <template-parameter-1-3> = <missing>]’
    /usr/include/c++/v1/type_traits:3121:72:   required from ‘struct std::__1::__libcpp_is_constructible<YAML::Node, const YAML::Node&>’
    /usr/include/c++/v1/type_traits:3145:29:   required from ‘struct std::__1::is_constructible<YAML::Node, const YAML::Node&>’
    /usr/include/c++/v1/utility:361:15:   required from ‘static constexpr bool std::__1::pair<_T1, _T2>::_CheckArgs::__enable_explicit() [with _U1 = const YAML::Node&; _U2 = const YAML::Node&; _T1 = YAML::Node; _T2 = YAML::Node]’
    /usr/include/c++/v1/utility:440:75:   required by substitution of ‘template<class _U1, class _U2, typename std::__1::enable_if<__enable_explicit<const _U1&, const _U2&>(), bool>::type <anonymous> > constexpr std::__1::pair<YAML::Node, YAML::Node>::pair(const std::__1::pair<_T1, _T2>&) [with _U1 = YAML::Node; _U2 = YAML::Node; typename std::__1::enable_if<__enable_explicit<const _U1&, const _U2&>(), bool>::type <anonymous> = <missing>]’
    /home/myname/yaml_cpp/include/yaml-cpp/node/iterator.h:24:52:   required from here
    /usr/include/c++/v1/utility:369:15: error: incomplete type ‘std::__1::is_constructible<YAML::Node, const YAML::Node&>’ used in nested name specifier
               return is_constructible<first_type, _U1>::value
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                   && is_constructible<second_type, _U2>::value
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions