我要评分
获取效率
正确性
完整性
易理解

An Early libstdc++ Library Version Resulting in Undefined Symbols or Incorrect Running Results

Error Information

The interface defined by the function in the C++ standard library of a later version cannot be found.

1
undefined reference to `std::xxx` 

Problem

By default, Clang uses the libstc++.so dynamic library in the system path. The libstdc++.so library of an earlier version may not support features of the later version used in the user code. As a result, undefined symbols or running result errors occur during linking.

Solution

Add the -stdlib=libc++ or -lc++ option during linking and use the C++ standard library in the libc++.so library provided by Clang.