I have this error:
permute_append.o: In function `CISP430_A5::charList_join(char const*, CISP430_A5::linked_list<char>)':
permute_append.cpp:(.text+0x0): multiple definition of `CISP430_A5::charList_join(char const*, CISP430_A5::linked_list<char>)'
main.o:main.cpp:(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [main] Error 1
What does the (.text+0x0) mean? I’m used to seeing line:column numbers (e.g. 57:68), but I have no idea what the (.text+0x0) means.
Here’s the code: https://gist.github.com/1340872/e25ec2aaac99c4005f4b33e6236750a2a6f1791f
It means the error was reported during linking, not compiling.
The link error is reported at the very start of the object module (my guess is before it emitted the first data into the .text segment).
In short: it’s immaterial here, but other linker errors my have a reference to e.g. the place where an unresolved external was used. Multiple definitions obviously occur in more than one location, which is apparently why the linker can’t decide what location to report.
Hint 99% of the time this happens when non-generic non-instance methods (in this case,
CISP430_A5::charList_join) are defined in header files instead of in cpp files. Is that method a static method?Edit Indeed the problem was that the method was defined inside the header. Line 201 of linked_list.h includes linked_list.template, meaning all definitions from linked_list.template are included. Effectively, that is the same as having the definition inside the header file directly.
Now, because
linked_list.his included in bothmain.cppandpermute_append.cppmain.oandpermute_append.oare being linked into themainexecutableyou’ll end up with two, conflicting definitions of the global free function
charList_join. I fixed things and uploaded to my gist