问题
Is there any reasons for 'symbol multiply defined' other than not having the declaration in .h, having it as 'extern', and have the implementation in .cpp?
I'm pretty sure that all my files follow the rule, but I'm getting an error message like this:
ld: lto: could not merge in /Users/zlw/Library/Developer/Xcode/DerivedData/Wireless -
amjmgyrircjezdhegioctszbcypz/Build/Intermediates/Wireless.build/Debug/Wireless.build/Objects
normal/x86_64/qam.o because 'Linking globals named '_Z12SNRFromSNRdBd': symbol multiply
defined!', using libLTO version 'LLVM version 3.3svn, from Apple Clang 5.0 (build
500.2.76)' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is the message means that all the troubles have something to do with 'qam.h' or 'qam.cpp'?
Is there any reasons other that 'extern' or is there any ways to see what is wrong with my code in Xcode?
Thank you very much!
回答1:
it says that when you compile qam.cpp
, you use a symbol named _Z12SNRFromSNRdBd
(corresponding to SNRFromSNRdB(double)
) which is defined more than once.
You should search for that function and who is implementing it.
Note : to convert from "mangled name" to human readable, you can use c++filt
bruce@lorien:~$ c++filt _Z12SNRFromSNRdBd
SNRFromSNRdB(double)
回答2:
I hope you can past your related code. That is clear. I got the similar error I hope may help you. That is A Function I declare in a.h and implement in a.c, then I invoke in b.c. It does work. If I change the a.c and b.c to a.cpp and b.cpp, it is wrong. The reason is CPP will change your function name for polymorphic.
来源:https://stackoverflow.com/questions/19397336/possible-reasons-for-symbol-multiply-defined-other-than-extern