调试 "multiple definition of ..." 错误的一般技巧?
General techniques for debugging the "multiple definition of ..." error?
我正在寻找一般调试"tricks"来寻找这种错误信息的根源问题:
build/nat.cpp.o:(.bss+0x0): multiple definition of `input::helloCounter'
build/sam.cpp.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
这里,input::helloCounter是在头文件中定义的全局变量,但是头文件用ifndef...
保护得很好。
这里粘贴源代码应该是没有意义的,因为太多了。但是我想知道您是否有一些通用的技术可以在这种情况下进行调试,例如通过插入一些特殊代码来暴露问题?有关信息,我使用 Ubuntu 14.04,Clang/g++ 作为编译器。
我正在寻找一般调试"tricks"来寻找这种错误信息的根源问题:
build/nat.cpp.o:(.bss+0x0): multiple definition of `input::helloCounter'
build/sam.cpp.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
这里,input::helloCounter是在头文件中定义的全局变量,但是头文件用ifndef...
保护得很好。
这里粘贴源代码应该是没有意义的,因为太多了。但是我想知道您是否有一些通用的技术可以在这种情况下进行调试,例如通过插入一些特殊代码来暴露问题?有关信息,我使用 Ubuntu 14.04,Clang/g++ 作为编译器。