[英]c++ - How to interpret symbols in 'duplicated symbols' error?
I'm working on a c++ program. 我正在研究一个c ++程序。
As several files are dependent on each other, I implemented them all in once and then I got compiling errors. 由于几个文件相互依赖,我一次性实现它们然后编译错误。
Here are those error messages: 以下是这些错误消息:
duplicate symbol __ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERNS_8Vector3DE in:
CMakeFiles/Rendr.dir/src/main.cpp.o
CMakeFiles/Rendr.dir/src/ray_tracer.cpp.o
duplicate symbol __ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_8Vector2DE in:
CMakeFiles/Rendr.dir/src/main.cpp.o
CMakeFiles/Rendr.dir/src/ray_tracer.cpp.o
duplicate symbol __ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERNS_8Vector3DE in:
CMakeFiles/Rendr.dir/src/main.cpp.o
CMakeFiles/Rendr.dir/src/CGL/svgparser.cpp.o
duplicate symbol __ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_8Vector2DE in:
CMakeFiles/Rendr.dir/src/main.cpp.o
CMakeFiles/Rendr.dir/src/CGL/svgparser.cpp.o
...
duplicate symbol __ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_8Vector2DE in:
CMakeFiles/Rendr.dir/src/main.cpp.o
CMakeFiles/Rendr.dir/src/CGL/triangulation.cpp.o
ld: 15 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [Rendr] Error 1
make[2]: *** [CMakeFiles/Rendr.dir/all] Error 2
make[1]: *** [CMakeFiles/Rendr.dir/rule] Error 2
make: *** [Rendr] Error 2
I'm not pasting my whole bunch of code because my problem is I can't understand things like __ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_8Vector2DE
, therefore I don't know how to locate the incorrect pieces of code. 我没有粘贴我的全部代码,因为我的问题是我无法理解像__ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_8Vector2DE
这样的__ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_8Vector2DE
,因此我不知道如何找到不正确的代码片段。
I've only run into symbols like _main
before and they are pretty easy to understand. 我之前只遇到像_main
这样的符号,它们很容易理解。
I have defined Vector3D
and Vector2D
classes, but how to interpret the exact symbols in the error messages? 我已经定义了Vector3D
和Vector2D
类,但是如何解释错误消息中的确切符号? I think they represent some functions or variables? 我认为它们代表了一些功能或变量?
Those are "decorated" or "mangled" names. 那些是“装饰”或“受损”的名字。 Different C++ compilers have different rules for name decoration. 不同的C ++编译器对名称修饰有不同的规则。
You can demangle them by using this handy online tool: https://demangler.com/ 您可以使用这个方便的在线工具对它们进行解码: https : //demangler.com/
For example: 例如:
__ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_8Vector2DE
is demangled to 取消了
_Rendr::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Rendr::Vector2D const&)
If you've got c++filt
available, you can do this at the command line: 如果你有c++filt
可用,你可以在命令行执行:
$ c++filt -_ __ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_8Vector2DE`
Rendr::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Rendr::Vector2D const&)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.