2
yaml-cpp 라이브러리를 사용하여 일부 YAML 문자열을 읽으 려합니다. 이를 위해, 나는 다음과 같은 C++ 코드를 컴파일하려고 :yaml-cpp : 연결에 실패했습니다.
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <openssl/sha.h>
#include <yaml-cpp/yaml.h>
int main(){
std::string yamlstr = "name: Test\ndescription: Test2";
std::stringstream is(yamlstr);
YAML::Parser parser(is);
YAML::Node doc;
parser.GetNextDocument(doc);
return 0;
}
그러나, 그것은 예상대로 작동하지 않습니다 내가 실행할 때 링커는 다음과 같은 오류 메시지가 발생합니다 g++ $(pkg-config --cflags --libs yaml-cpp) test.cpp -o test
:
/tmp/ccEPCiDN.o: In function `main':
test.cpp:(.text+0x1e0): undefined reference to `YAML::Parser::Parser(std::basic_istream<char, std::char_traits<char> >&)'
test.cpp:(.text+0x1ef): undefined reference to `YAML::Node::Node()'
test.cpp:(.text+0x209): undefined reference to `YAML::Parser::GetNextDocument(YAML::Node&)'
test.cpp:(.text+0x218): undefined reference to `YAML::Node::~Node()'
test.cpp:(.text+0x227): undefined reference to `YAML::Parser::~Parser()'
test.cpp:(.text+0x403): undefined reference to `YAML::Node::~Node()'
test.cpp:(.text+0x412): undefined reference to `YAML::Parser::~Parser()'
collect2: ld returned 1 exit status
pkg-config --cflags --libs yaml-cpp
의
출력 :
-I/usr/local/include -L/usr/local/lib -lyaml-cpp
출력 ls -l /usr/local/lib
의 :
[...]
-rw-r--r-- 1 root root 843138 2012-03-01 10:38 libyaml-cpp.a
[...]
현재 버전 0.3.0을 사용하고 있지만 현재 저장소도 체크 아웃했습니다.
누구든지이 문제를 해결하는 방법을 알고 있습니까?
고마워요!/usr/lib에 매우 오래된 libyaml이 있습니다. 내가 그것을 제거한 후에, 모든 것이 잘 작동했다. – SecStone