Problem linking to wrong class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
This is the oddest problem I have ever seen. I am using Fedora 8 and gcc
(GCC) 4.1.2 20070925 (Red Hat 4.1.2-33). I have two classes with the
same name SqlQuery. One is in a static library (libone.a) and one is in
a shared library (libtwo.so).
I have a class that is in the shared library only (DBI), that calls a
method in SqlQuery. There is a method of the same name and parameters in
the shared and static library: void clear(std::string& query).
I build the shared library without any reference to static library. I
build the static library without any reference to the shared library. My
program links both the shared and the static library into them without
any errors or warnings about symbol clashes.
When I run my program calls a method in the DBI class (which is in the
shared library), it crashes. Using gdb, the crash appears to be in the
SqlQuery in the static library, not the shared library. Which makes no
sense to me, as the libraries were built without any reference to each
other. I can repoduce this every time with 2 different code paths, both
eventually calling a common method.
If I add a namespace to the SqlQuery class in the shared library, the
crash does not occur. But my code base is well over a millions lines of
code and trying to do this everywhere a potential issue may be a is a
daunting task. I have other common class names (and method definitions)
that aren't causing crashes, but at this point, I am not sure they are
calling the correct methods either.
Any ever heard of something like this? I am assuming it is some sort of
linker problem. But I don't understand why I am not getting warnings
about shared symbols.
- B
[Index of Archives]
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]