0

I am newbie to cmake and I am pretty sure this is the problem I am facing here.

I am trying to use the yaml-cpp library which is written in cmake project into my own cmake project. I run the following commands to build and install the yaml-cpp in it's own directory. mkdir build, cd build, cmake .., make, and then sudo make install and no errors occured after running those commands.

now in my own project I am having a c++ code file in a proper cmake project. To use the yaml-cpp library I am including it with the #include "yaml-cpp/yaml.h", and in the CmakeLists.txt file in that subdirectory I am adding the following two:

find_package(yaml-cpp REQUIRED)
target_link_libraries(yaml-cpp)

however when I try to compile the project it gives me the following output:

handstandForm.cpp:(.text+0x4820): undefined reference to `YAML::LoadFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

I want to point out that the project compiles perfectly and run without any errors when deleting any lines of codes using the yaml-cpp library. what could be the problem? Please help.

  • 1
    Does this answer your question? [Finding correct cmake configuration for c++ library](https://stackoverflow.com/questions/51036144/finding-correct-cmake-configuration-for-c-library) The `target_link_libraries()` command requires *at least* two arguments. The first argument must be an existing CMake target, which would be *your* library/executable that you want to link the library to. – Kevin Apr 28 '20 at 14:52
  • no it does not. – ShehabAldeen May 17 '20 at 05:20

0 Answers0