Hello,
I'm working on refactoring a suite of old utilities and creating a new server that's going to use common code from all of them to unify their functionality and allow external access by remote clients. For each utility, I'm taking the code I need for the server and refactoring it out into a shared library so that the utility and the server will now both link against the shared library. Because of the way the former implementor of these utilites did things, they pretty much just copied and pasted everything whenever they needed to create a new utility, so there's a ton of functions that have the same signature (ie callbacks for an XML parser) but do different things inside.
When I run the standalone utilities which have been refactored to link against the shared code, they work perfectly. When I try to use the server with the same functionality as a given utility, the server is using code from the first library linked in, instead of the library it should be taking functionality from.
For example, I have xml for devices A, B, C that get parsed by a common xml library, but each device has its own shared library libA, libB, libC that's used by the server. When I make a call to the server to send xml for device C, it's using the function 'HandleStartElement' from libA, instead of the function of same name and signature in libC, even though the shared libraries only declare these functions internally and don't share any headers that mention these internal callbacks for parsing xml.
Can somebody please explain to me why it's not reading the proper function, and how to avoid this in the future ?
My makefile for the server has the following flags for the compilation of the main program :
-I../include -L../lib -lA -lB -lC
Each shared library is using next to no flags for the shared library, and is not using -fPIC.