0

I installed libyaml-cpp-dev via sudo apt install libyaml-cpp-dev and got yaml-cpp 0.5 version installed on my machine.

dpkg -s libyaml-cpp-dev | grep Version
Version: 0.5.2-4ubuntu1

Using this , I tried to build a testing code, demo.cpp as below:

#include <string>
#include "yaml-cpp/yaml.h"

int main(){
  std::string config_file{"/home/freyr/exper/yamp-cpp/rvs.conf"};
  YAML::Node config = YAML::LoadFile(config_file);
  return 0;
}

with a cmake,

cmake_minimum_required (VERSION 2.8.11)
project (HELLO)
find_package(yaml-cpp REQUIRED)
add_executable (helloDemo demo.cpp)
include_directories(${YAML_CPP_INCLUDE_DIRS})
target_link_libraries(helloDemo ${YAML_CPP_LIBRARIES})

When I tried to build , I get below error:

make: Entering directory '/home/freyr/exper/yamp-cpp/build' make[1]: Entering directory '/home/freyr/exper/yamp-cpp/build' make[2]: Entering directory '/home/freyr/exper/yamp-cpp/build' Scanning dependencies of target helloDemo make[2]: Leaving directory '/home/freyr/exper/yamp-cpp/build' make[2]: Entering directory '/home/freyr/exper/yamp-cpp/build' [ 50%] Building CXX object CMakeFiles/helloDemo.dir/demo.cpp.o In file included from /usr/include/yaml-cpp/node/iterator.h:13:0,
                 from /usr/include/yaml-cpp/node/impl.h:11,
                 from /usr/include/yaml-cpp/yaml.h:17,
                 from /home/freyr/exper/yamp-cpp/demo.cpp:3: /usr/include/yaml-cpp/node/detail/iterator.h: In member function ‘void YAML::detail::iterator_base<V>::increment()’: /usr/include/yaml-cpp/node/detail/iterator.h:48:54: error: ‘next’ is not a member of ‘boost’    void increment() { this->base_reference() = boost::next(this->base()); }
                                                      ^~~~ /usr/include/yaml-cpp/node/detail/iterator.h:48:54: note: suggested alternatives: In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from /home/freyr/exper/yamp-cpp/demo.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:208:5: note:   ‘std::next’
     next(_ForwardIterator __x, typename
     ^~~~ In file included from /usr/local/include/boost/mpl/next.hpp:17:0,
                 from /usr/local/include/boost/mpl/bind.hpp:25,
                 from /usr/local/include/boost/mpl/lambda.hpp:18,
                 from /usr/local/include/boost/mpl/apply.hpp:25,
                 from /usr/local/include/boost/iterator/iterator_facade.hpp:36,
                 from /usr/include/yaml-cpp/node/detail/node_iterator.h:12,
                 from /usr/include/yaml-cpp/node/detail/iterator.h:12,
                 from /usr/include/yaml-cpp/node/iterator.h:13,
                 from /usr/include/yaml-cpp/node/impl.h:11,
                 from /usr/include/yaml-cpp/yaml.h:17,
                 from /home/freyr/exper/yamp-cpp/demo.cpp:3: /usr/local/include/boost/mpl/next_prior.hpp:29:8: note:   ‘boost::mpl::next’  struct next
        ^~~~ CMakeFiles/helloDemo.dir/build.make:62: recipe for target 'CMakeFiles/helloDemo.dir/demo.cpp.o' failed make[2]: *** [CMakeFiles/helloDemo.dir/demo.cpp.o] Error 1 make[2]: Leaving directory '/home/freyr/exper/yamp-cpp/build' CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/helloDemo.dir/all' failed make[1]: *** [CMakeFiles/helloDemo.dir/all] Error 2 make[1]: Leaving directory '/home/freyr/exper/yamp-cpp/build' Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

I see in latest https://github.com/jbeder/yaml-cpp/blob/master/include/yaml-cpp/node/detail/iterator.h there are no references to boost ad it is all std c++ alone. How do I install latest version of libyaml-cpp-dev which has no boost dependencies ? I dont want to build and install from latest version as git cloning from master every time will not be a very secure practice.

1 Answer 1

0

yaml-cpp introduced boost dependency in version 0.5 and removed it in version 0.6. You need to upgrade your Ubuntu to a newer release or install yaml-cpp from sources, or install a version of yaml-cpp older than 0.5.

See: https://yaml-cpp.docsforge.com/#how-to-build

yaml-cpp 0.6.0 has been released! This release requires C++11, and no longer depends on Boost.

See also https://www.ubuntuupdates.org/package/core/hirsute/main/base/yaml-cpp - the current version of yaml-cpp in Ubuntu 21.4 is 0.6.3-9ubuntu1

Sign up to request clarification or add additional context in comments.

2 Comments

Installing yaml-cpp from sources is not possible in certain air-gapped setups which cannot clone from yaml sources. I am using Ubuntu 18.04, for which apt gets me libyaml-0.5 which sadly has boost dependencies. I was looking for a way to specify versions using which latest package gets installed. None of the appendings like libyaml-cpp-dev0.6 or libyaml-cpp-dev0.6.3-10 work.
Ubuntu should have a possibility to install (downgrade to) older packages, that is, 0.4.* or earlier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.