我已经构建了yaml-cpp,然后也做了
make install
现在一切都已完成并设置。 现在,我有一个c ++文件,该文件正在解析用户代理字符串。 我使用了来自github的uap-cpp库进行解析,该库依赖yaml-cpp。
我已经在Mac机器上运行了相同的c ++文件,没有任何问题。但是,当我在Ubuntu(linux)上运行相同的文件时,在下面出现此错误。
cc-user-2154@CC-USER-2154:~/Desktop/cocubes/uap-cpp$ g++ example.cpp libuaparser_cpp.a -L /usr/local/lib/ -lyaml-cpp -lboost_regex -std=c++11
cc-user-2154@CC-USER-2154:~/Desktop/cocubes/uap-cpp$ ./a.out
terminate called after throwing an instance of 'YAML::BadFile'
what(): bad file
Aborted (core dumped)
现在发生了一件有趣的事情。 我跑了命令 sudo apt-get install libyaml-cpp-dev
现在,它在编译时引发错误。错误是
cc-user-2154@CC-USER-2154:~/Desktop/cocubes/uap-cpp$ g++ example.cpp libuaparser_cpp.a -lyaml-cpp -lboost_regex -std=c++11
libuaparser_cpp.a(UaParser.o): In function `YAML::TypedBadConversion<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::~TypedBadConversion()':
/home/cc-user-2154/Desktop/cocubes/yaml-cpp/include/yaml-cpp/exceptions.h:212: undefined reference to `YAML::BadConversion::~BadConversion()'
libuaparser_cpp.a(UaParser.o): In function `YAML::TypedBadConversion<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::~TypedBadConversion()':
/home/cc-user-2154/Desktop/cocubes/yaml-cpp/include/yaml-cpp/exceptions.h:212: undefined reference to `YAML::BadConversion::~BadConversion()'
libuaparser_cpp.a(UaParser.o): In function `YAML::BadConversion::BadConversion(YAML::Mark const&)':
/home/cc-user-2154/Desktop/cocubes/yaml-cpp/include/yaml-cpp/exceptions.h:206: undefined reference to `vtable for YAML::BadConversion'
libuaparser_cpp.a(UaParser.o): In function `YAML::detail::node& YAML::detail::node_data::get<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<YAML::detail::memory_holder>)':
/home/cc-user-2154/Desktop/cocubes/yaml-cpp/include/yaml-cpp/node/detail/impl.h:143: undefined reference to `YAML::detail::node_data::convert_to_map(std::shared_ptr<YAML::detail::memory_holder>)'
libuaparser_cpp.a(UaParser.o):(.data.rel.ro._ZTIN4YAML18TypedBadConversionINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE[_ZTIN4YAML18TypedBadConversionINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE]+0x10): undefined reference to `typeinfo for YAML::BadConversion'
collect2: error: ld returned 1 exit status