I have a working C library that I want to associate with a C ++ application using gcc, but the linker (g ++) gives me a "multiple definition" error. Using the C application and gcc it works. The headers defining the interface contain:
#ifdef __cplusplus
extern "C" {
#endif
I checked the library with the "nm" command, and it has several method definitions (this method is not from the public interface).
My questions:
Why does my library have several definitions (some have T and others have U)?
Why does this work if the application, including the file, is a C application (I use -Wall to build)?
Do I need any special attribute or use a specific file extension for it to work, or if I need to return to the programming school :)?
Paying more attention to the lib.a file, I see that one of the objects is included twice. For example, I have two sections for the same object:
obj1.o
00000000 T Method
obj2.o
00000000 T Hello
obj1.o
00000000 T Method
I think this is a problem?
Any help really appreciated.
Andre source
share