I'm attempting to compile a relatively simple program using yaml-cpp 0.5.3 with g++ 7.1.0, and am getting a linker error. The minimal program code is:
#include <yaml-cpp/yaml.h>
int main(int i_iArg_Count, char * i_lpszArg_Values[])
{
std::string cszFilename = i_lpszArg_Values[1];
YAML::Node cFile;
cFile = YAML::LoadFile(cszFilename);
return 0;
}
This code compiles and links just fine under g++ 4.9.0, but under g++ 7.1.0 I get the error
/tmp/ccJruju7.o: In function `main':
tyaml.cpp:(.text+0x19e): undefined reference to `YAML::LoadFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
The compile command I am using for this case is g++ tyaml.cpp -lyaml-cpp -o tyaml
. I can confirm that it is not a problem with the path to the library -- LIBRARY_PATH
contains the correct path to libyaml-cpp.a and g++ 4.9.0 compiles it fine with the same path. The more complete code uses more of yaml-cpp, and it is only functions that require std::string that are causing the problem.
libyaml-cpp.a was compiled using g++ 7.1.0, so I don't think it is an issue with the library itself. I have confirmed that the library includes the YAML::LoadFile
symbol, and takes type std::string const &
I am not able to continue using older versions of g++ on the system that I am using.
I have tried both yaml-cpp 0.5.1 and yaml-cpp 0.5.3, both suffer from the same problem. I suspect this is a problem with std::string implementation in some way.