Errors Encountered While Integrating the Libpqxx code with our Library.
- While integrating the libraries all of them should have the “Runtime Library” property set to “Multi-threaded Debug DLL (/MDd)”. Even if one of the libraries has different runtime library the console application project will give Linking errors. The errors are mostly “error LNK 2005” errors. For example like the one, TestRouteXMLGenerator error LNK2005: "public: __thiscall std::_Locinfo::_Locinfo(char const *)" (??0_Locinfo@std@@QAE@PBD@Z) already defined in msvcprtd.lib(MSVCP71D.dll).
Solution: All the libraries should have the “Runtime Library” property set to “Multi-threaded Debug DLL (/MDd)”.
- We were building all of our libraries in DEBUG mode and linking the Test console project with DEBUG version of static libraries except that of libpqxx as we did not have its DEBUG version. We got the following (Debug Assertion Failed) error at the point where we used to make the call to the libpqxx code when we linked with the release version of the library.
We did not get this error in the Release version since we were linking with the release version of libpqxx library.
We created the DEBUG verion of the libpqxx library the libqxxd.lib and linked with it.
- The struct member alignment problem: The libpqxx library was created using the default struct member alignment of “8 Bytes”. All of our libraries are created using the struct member alignment of “1 Byte”. We got the following error just before the libpqxx code was ended.
Solution: Used #pragma pack to toggle between the two struct member alignments.
We put all the header files of libpqxx between the statements #pragma pack(push,8), to change to 8 bytes and #pragma pop (to get back to original stuct alignment of 1 byte ).