Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » yaml-cpp(yaml-cpp in eclipse)
yaml-cpp [message #1847380] Mon, 25 October 2021 17:35 Go to next message
Eryk Wawrzyn is currently offline Eryk WawrzynFriend
Messages: 3
Registered: October 2021
Junior Member
Hi,

is it possible to add a library to a project in eclipse?
If yes, how can it be done?

Help!
Thanks
Re: yaml-cpp [message #1847391 is a reply to message #1847380] Mon, 25 October 2021 19:56 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Assuming you mean "Use a library",
the steps needed are:


  1. Tell the compiler where the headers can be found
  2. Tell the linker where the library can be found
  3. Tell the indexer where the headers can be found


If you are using GCC/G++, you tell the compiler where the headers are with the
-I flag and tell the linker with the -L and -l (small L) flags. Clang
is similar but I don't use it and can't say for sure.

You should learn to use the compiler and linker outside of Eclipse. It will help
you understand what Eclipse will need to know to build recipes using those tools.

If you are using a Managed Build project using Make, you can set the compiler
and linker flags with
Project --> Properties --> C/C++ Build --> Settings --> Tool settings tab

You tell the Indexer where the headers are by using
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.

If you are using a Managed Build with Make you can do all with
Project --> Properties --> C/C++ General --> Paths and Symbols

If you are using a build system other than Make then you need to understand
how to tell it (1) and (2).





Re: yaml-cpp [message #1847415 is a reply to message #1847391] Tue, 26 October 2021 15:33 Go to previous messageGo to next message
Eryk Wawrzyn is currently offline Eryk WawrzynFriend
Messages: 3
Registered: October 2021
Junior Member
Hi,

thanks for your help David VavraFriend.

In the terminal (Ubuntu system) I can compile the code with the instruction "g++ -L/usr/local/lib -I/usr/local/include tmp.cpp -lyaml-cpp".

In Managed Build
Project --> Properties --> C/C++ General --> Paths and Symbols-->Includes-->GNU C++
I added directory: /usr/local/include
Project --> Properties --> C/C++ General --> Paths and Symbols-->Library Paths
I added directory: /usr/local/lib

In "Project Settings" I added -lyaml-cpp in "Linker Flages".

But I still get errors during compilation:
obj/tmp.o: In function `YAML::Node::Scalar[abi:cxx11]() const':
/usr/local/include/yaml-cpp/node/impl.h:169: undefined reference to `YAML::detail::node_data::empty_scalar[abi:cxx11]()'
obj/tmp.o: In function `YAML::detail::node& YAML::detail::node_data::get<char [5]>(char const (&) [5], std::shared_ptr<YAML::detail::memory_holder>)':
/usr/local/include/yaml-cpp/node/detail/impl.h:154: undefined reference to `YAML::detail::node_data::convert_to_map(std::shared_ptr<YAML::detail::memory_holder> const&)'
obj/tmp.o: In function `YAML::detail::node& YAML::detail::node_data::get<char [6]>(char const (&) [6], std::shared_ptr<YAML::detail::memory_holder>)':
/usr/local/include/yaml-cpp/node/detail/impl.h:154: undefined reference to `YAML::detail::node_data::convert_to_map(std::shared_ptr<YAML::detail::memory_holder> const&)'
obj/tmp.o: In function `YAML::detail::node& YAML::detail::node_data::get<char [2]>(char const (&) [2], std::shared_ptr<YAML::detail::memory_holder>)':
/usr/local/include/yaml-cpp/node/detail/impl.h:154: undefined reference to `YAML::detail::node_data::convert_to_map(std::shared_ptr<YAML::detail::memory_holder> const&)'
obj/tmp.o: In function `YAML::detail::node& YAML::detail::node_data::get<char [3]>(char const (&) [3], std::shared_ptr<YAML::detail::memory_holder>)':
/usr/local/include/yaml-cpp/node/detail/impl.h:154: undefined reference to `YAML::detail::node_data::convert_to_map(std::shared_ptr<YAML::detail::memory_holder> const&)'
/usr/lib/x86_64-linux-gnu/libyaml-cpp.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()@GLIBCXX_3.4.26'

Did I add something in eclipse incorrectly ?



Re: yaml-cpp [message #1847417 is a reply to message #1847415] Tue, 26 October 2021 16:22 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
In Paths and Symbols --> Libraries tab
or Project --> Properties --> Settings --> Tool Settings tab --> GCC Linker --> Libraries --> top pane
you just set "yaml-cpp" (without the small L) if that's the library name.

Can you show the entire build log?
I need to see the compile and link commands.
The order of the -l (small L) and -L flags is important.
The Linker Flags are placed on the command line first
and you need -lyaml-cpp at the end.




Re: yaml-cpp [message #1847420 is a reply to message #1847417] Tue, 26 October 2021 17:57 Go to previous message
Eryk Wawrzyn is currently offline Eryk WawrzynFriend
Messages: 3
Registered: October 2021
Junior Member
Hi,

thanks for your help David VavraFriend.
I have already solved the problem. In "Project Settings" I added "-L/usr/local/lib -I/usr/local/include -lyaml-cpp" in "Linker Flags".
Previous Topic:Link external code from folder C++
Next Topic:Cmake build error
Goto Forum:
  


Current Time: Thu Apr 25 22:29:29 GMT 2024

Powered by FUDForum. Page generated in 0.02825 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top