Unable to build any application that uses yaml-cpp, linker errors

Open
#1,219 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cmake, cpp
Domain
build-system

Research direction

Start by reading the CMakeLists.txt in the issue and checking how yaml-cpp is found and linked against the application. Reproduce the undefined references with the shown linker output, then verify that the application links the matching yaml-cpp library; done when the build completes without those unresolved symbols.

Written by the indexing model from the issue text.

Description

I am building an application that uses yaml-cpp but I get these errors:

/usr/bin/ld: CMakeFiles/transcribe.dir/transcribe.cpp.o: in function `returnVocabulary(std::string const&)':
transcribe.cpp:(.text+0x55786): undefined reference to `YAML::LoadFile(std::string const&)'
/usr/bin/ld: CMakeFiles/transcribe.dir/transcribe.cpp.o: in function `YAML::detail::node_ref::set_scalar(std::string const&)':
transcribe.cpp:(.text._ZN4YAML6detail8node_ref10set_scalarERKSs[_ZN4YAML6detail8node_ref10set_scalarERKSs]+0x2e): undefined reference to `YAML::detail::node_data::set_scalar(std::string const&)'
/usr/bin/ld: CMakeFiles/transcribe.dir/transcribe.cpp.o: in function `YAML::Node::Scalar() const':
transcribe.cpp:(.text._ZNK4YAML4Node6ScalarEv[_ZNK4YAML4Node6ScalarEv]+0x7d): undefined reference to `YAML::detail::node_data::empty_scalar()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/transcribe.dir/build.make:113: transcribe] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/transcribe.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

My CMakeLists.txt is as follows:

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(transcribe)

include_directories(
    ${CMAKE_SOURCE_DIR}
    /home/divyansh/Documents/onnxruntime-linux-x64-gpu-1.15.1/include
    ${CMAKE_SOURCE_DIR}/yaml-cpp/include/yaml-cpp
)
link_directories(/home/divyansh/Documents/onnxruntime-linux-x64-gpu-1.15.1/lib
                ${CMAKE_SOURCE_DIR}/yaml-cpp/build
                )
set(Torch_DIR /home/divyansh/.local/lib/python3.10/site-packages/torch/share/cmake/Torch)
find_package(Torch REQUIRED)
find_package(yaml-cpp REQUIRED)
link_libraries(${CMAKE_SOURCE_DIR}/yaml-cpp/build/libyaml-cpp.a)
add_executable(transcribe transcribe.cpp)
target_link_libraries(transcribe PRIVATE "${TORCH_LIBRARIES}" onnxruntime yaml-cpp)
set_property(TARGET transcribe PROPERTY CXX_STANDARD 17)
Dominant language
C++
Stars
6.1k
Forks
2.2k
Avg merge
22h 2m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jbeder/yaml-cpp

All issues in jbeder/yaml-cpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.