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

Aperta
#1,219 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
cmake, cpp
Ambito
build-system

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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)
Lingua principale
C++
Stelle
6.1k
Fork
2.2k
Merge medio
22h 2m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jbeder/yaml-cpp

Tutte le issue di jbeder/yaml-cpp

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.