I'm working on a c++ program.
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.
I've only run into symbols like _main
before and they are pretty easy to understand.
I have defined Vector3D
and Vector2D
classes, but how to interpret the exact symbols in the error messages? I think they represent some functions or variables?
Those are "decorated" or "mangled" names. Different C++ compilers have different rules for name decoration.
You can demangle them by using this handy online tool: 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 -_ __ZN5RendrlsERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEERKNS_8Vector2DE`
Rendr::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Rendr::Vector2D const&)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.