Multiple Definition error
-
Hi, there are hundreds of posts on the internet about this but i still don't get it. I am writing a windows program using the g++ compiler and the RAD C++ library[^]. I get these errors:
WarpFile.o(.text+0x0): In function `ZN11_RADCPP_APP12getBuildTimeEv':
C:/Program Files/Dev-Cpp/include/radc++.h:2182: multiple definition of `_RADCPP_APP::getBuildTime()'
Main.o(.text+0x6a0):C:/Program Files/Dev-Cpp/include/radc++.h:2182: first defined here
WarpFile.o(.text+0x30): In function `ZN11_RADCPP_APP12getBuildDateEv':
C:/Program Files/Dev-Cpp/include/radc++.h:2181: multiple definition of `_RADCPP_APP::getBuildDate()'
Main.o(.text+0x6d0):C:/Program Files/Dev-Cpp/include/radc++.h:2181: first defined here
WarpFile.o(.bss+0x0): In function `ZN11_RADCPP_APP12getBuildTimeEv':
etc...Can someone please look at my code (here[^]) and tell me what i'm doing wrong. Or alternatively explain how i can prevent this error. I know it's because something has been defined in two object files but i don't know how to stop it
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
-
Hi, there are hundreds of posts on the internet about this but i still don't get it. I am writing a windows program using the g++ compiler and the RAD C++ library[^]. I get these errors:
WarpFile.o(.text+0x0): In function `ZN11_RADCPP_APP12getBuildTimeEv':
C:/Program Files/Dev-Cpp/include/radc++.h:2182: multiple definition of `_RADCPP_APP::getBuildTime()'
Main.o(.text+0x6a0):C:/Program Files/Dev-Cpp/include/radc++.h:2182: first defined here
WarpFile.o(.text+0x30): In function `ZN11_RADCPP_APP12getBuildDateEv':
C:/Program Files/Dev-Cpp/include/radc++.h:2181: multiple definition of `_RADCPP_APP::getBuildDate()'
Main.o(.text+0x6d0):C:/Program Files/Dev-Cpp/include/radc++.h:2181: first defined here
WarpFile.o(.bss+0x0): In function `ZN11_RADCPP_APP12getBuildTimeEv':
etc...Can someone please look at my code (here[^]) and tell me what i'm doing wrong. Or alternatively explain how i can prevent this error. I know it's because something has been defined in two object files but i don't know how to stop it
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
I can not see the problem in your code, which implies it may be in the header. I could not figure out how to decompress the library download, so I could not look at “regc++.h” to check if it has code guards defined. Try moving the ‘#include “regc++.h”’ from the header file ‘common.h’ and only include it in the files that need it. Beyond that I can not tell why the errors are occurring. Good Luck!
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
-
I can not see the problem in your code, which implies it may be in the header. I could not figure out how to decompress the library download, so I could not look at “regc++.h” to check if it has code guards defined. Try moving the ‘#include “regc++.h”’ from the header file ‘common.h’ and only include it in the files that need it. Beyond that I can not tell why the errors are occurring. Good Luck!
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
Yes, i fiddled around with the code and merged Graphics.cpp with Main.cpp and made a Main.h where i did the same thing. It eventually worked, probably because, like you said, i only included things in the files that needed it. btw, the library is "radc++.h" not "regc++.h" and i just remembered that i downloaded and installed it in Dev-C++. But all you need to know it that it is purely based on Microsoft Window API, no external libraries.
Customer in computer shop: "Can you copy the Internet onto this disk for me?"