Link2005 error when attempting to build project in visual studio IDE that uses libpqxx C++ wrapper for the libpq C API in visual studio
-
Hello, I've built the libpq C API and libpqxx C++ wrapper for the API using visual studio/nmake, and passed all 95 (base zero 94) Static release tests from the command line using nmake/ a special makefile. I have the following files in my libpqxx-2.6.9\lib folder (not my libpqxx-2.6.9\win32\lib folder, which seems to be where they're expected to be): libpq.dll libpqd.dll libpqxx.dll libpqxx.dll.manifest libpqxx.exp libpqxx.lib libpqxx_static.lib libpqxx_staticD.lib libpqxxD.dll libpqxxD.dll.manifest libpqxxD.exp libpqxxD.ilk libpqxxD.lib libpqxxD.pdb Now all that remains is to get libpqxx projects compiling from within the visual studio IDE. I have followed Alexandre Hanft's instructions (found in install.txt, which comes with the wrapper) on getting a libpqxx project to compile in visual studio very carefully. Specifically, in my project's properties: Under C++::General::Additional Include Directories, I have "C:\libpqxx-2.6.9\include" for all configurations. Under Linker::General::Additional Library directories, I have placed C:\libpq\src\interfaces\libpq\Debug;"C:\libpqxx-2.6.9\lib" for the Debug and C:\libpq\src\interfaces\libpq\Release;"C:\libpqxx-2.6.9\lib" for the Release. Under Linker::Input::Additional Dependencies, I have placed "libpqxx.lib" for all configurations. Here is my compiler output. There are many link2005 errors(see http://support.microsoft.com/kb/148652) :
1>------ Rebuild All started: Project: myfirspostgresprogram, Configuration: Debug Win32 ------ 1>Deleting intermediate and output files for project 'myfirspostgresprogram', configuration 'Debug|Win32' 1>Compiling... 1>cl : Command line warning D9002 : ignoring unknown option '/NODEFAULTLIB:library' 1>postgres.cpp 1>Compiling manifest to resources... 1>Linking... 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "public: unsigned long __thiscall pqxx::result::size(void)const " (?size@result@pqxx@@QBEKXZ) already defined in libpqxx.lib(libpqxx.dll) 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "public: bool __thiscall pqxx::result::empty(void)const " (?empty@result@pqxx@@QBE_NXZ) already defined in libpqxx.lib(libpqxx.dll) 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "private: char const * __thiscall pqxx::result:::^)GetValue(unsigned long,unsigned int)const " (?GetValue@result@pqxx@@ABEPBDKI@Z) already defined in libpqxx.lib(libpqxx.dll) 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "private: bool __thiscall pqxx::result::GetIsNull(unsigned long,unsigned int)cons
-
Hello, I've built the libpq C API and libpqxx C++ wrapper for the API using visual studio/nmake, and passed all 95 (base zero 94) Static release tests from the command line using nmake/ a special makefile. I have the following files in my libpqxx-2.6.9\lib folder (not my libpqxx-2.6.9\win32\lib folder, which seems to be where they're expected to be): libpq.dll libpqd.dll libpqxx.dll libpqxx.dll.manifest libpqxx.exp libpqxx.lib libpqxx_static.lib libpqxx_staticD.lib libpqxxD.dll libpqxxD.dll.manifest libpqxxD.exp libpqxxD.ilk libpqxxD.lib libpqxxD.pdb Now all that remains is to get libpqxx projects compiling from within the visual studio IDE. I have followed Alexandre Hanft's instructions (found in install.txt, which comes with the wrapper) on getting a libpqxx project to compile in visual studio very carefully. Specifically, in my project's properties: Under C++::General::Additional Include Directories, I have "C:\libpqxx-2.6.9\include" for all configurations. Under Linker::General::Additional Library directories, I have placed C:\libpq\src\interfaces\libpq\Debug;"C:\libpqxx-2.6.9\lib" for the Debug and C:\libpq\src\interfaces\libpq\Release;"C:\libpqxx-2.6.9\lib" for the Release. Under Linker::Input::Additional Dependencies, I have placed "libpqxx.lib" for all configurations. Here is my compiler output. There are many link2005 errors(see http://support.microsoft.com/kb/148652) :
1>------ Rebuild All started: Project: myfirspostgresprogram, Configuration: Debug Win32 ------ 1>Deleting intermediate and output files for project 'myfirspostgresprogram', configuration 'Debug|Win32' 1>Compiling... 1>cl : Command line warning D9002 : ignoring unknown option '/NODEFAULTLIB:library' 1>postgres.cpp 1>Compiling manifest to resources... 1>Linking... 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "public: unsigned long __thiscall pqxx::result::size(void)const " (?size@result@pqxx@@QBEKXZ) already defined in libpqxx.lib(libpqxx.dll) 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "public: bool __thiscall pqxx::result::empty(void)const " (?empty@result@pqxx@@QBE_NXZ) already defined in libpqxx.lib(libpqxx.dll) 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "private: char const * __thiscall pqxx::result:::^)GetValue(unsigned long,unsigned int)const " (?GetValue@result@pqxx@@ABEPBDKI@Z) already defined in libpqxx.lib(libpqxx.dll) 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "private: bool __thiscall pqxx::result::GetIsNull(unsigned long,unsigned int)cons
Did you configure the Project properties for Linker --> Input --> Additional Dependencies. ?
Maxwell Chen
-
Did you configure the Project properties for Linker --> Input --> Additional Dependencies. ?
Maxwell Chen
Yes. I've just added libpqxx.lib, per the instructions in the readme file, Regards, Sternocera
-
Yes. I've just added libpqxx.lib, per the instructions in the readme file, Regards, Sternocera
The problem is that I cannot link to libpqxx_static.lib/libpqxx_staticD.lib and not to libpqxx.lib/libpqxxD.lib (fatal error LNK1104: cannot open file), and, conversely, I cannot link to libpqxx.lib/libpqxxD.lib and not to libpqxx_static.lib/libpqxx_staticD.lib (fatal error LNK1104: cannot open file). They are dependent on each other, but prevent each other from working, it would seem!
-
Did you configure the Project properties for Linker --> Input --> Additional Dependencies. ?
Maxwell Chen
by apending more input to my additional dependencies (essentially all my libs, both those of the wrapper and the underlieing api), I get the following linker errors:
1>ibpq.lib(fe-misc.obj) : error LNK2001: unresolved external symbol __imp__select@20 1>libpq.lib(fe-connect.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0 1>libpq.lib(fe-misc.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0 // lots more similar linker errors
What do you think these mean? Regards, Sternocera -
Hello, I've built the libpq C API and libpqxx C++ wrapper for the API using visual studio/nmake, and passed all 95 (base zero 94) Static release tests from the command line using nmake/ a special makefile. I have the following files in my libpqxx-2.6.9\lib folder (not my libpqxx-2.6.9\win32\lib folder, which seems to be where they're expected to be): libpq.dll libpqd.dll libpqxx.dll libpqxx.dll.manifest libpqxx.exp libpqxx.lib libpqxx_static.lib libpqxx_staticD.lib libpqxxD.dll libpqxxD.dll.manifest libpqxxD.exp libpqxxD.ilk libpqxxD.lib libpqxxD.pdb Now all that remains is to get libpqxx projects compiling from within the visual studio IDE. I have followed Alexandre Hanft's instructions (found in install.txt, which comes with the wrapper) on getting a libpqxx project to compile in visual studio very carefully. Specifically, in my project's properties: Under C++::General::Additional Include Directories, I have "C:\libpqxx-2.6.9\include" for all configurations. Under Linker::General::Additional Library directories, I have placed C:\libpq\src\interfaces\libpq\Debug;"C:\libpqxx-2.6.9\lib" for the Debug and C:\libpq\src\interfaces\libpq\Release;"C:\libpqxx-2.6.9\lib" for the Release. Under Linker::Input::Additional Dependencies, I have placed "libpqxx.lib" for all configurations. Here is my compiler output. There are many link2005 errors(see http://support.microsoft.com/kb/148652) :
1>------ Rebuild All started: Project: myfirspostgresprogram, Configuration: Debug Win32 ------ 1>Deleting intermediate and output files for project 'myfirspostgresprogram', configuration 'Debug|Win32' 1>Compiling... 1>cl : Command line warning D9002 : ignoring unknown option '/NODEFAULTLIB:library' 1>postgres.cpp 1>Compiling manifest to resources... 1>Linking... 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "public: unsigned long __thiscall pqxx::result::size(void)const " (?size@result@pqxx@@QBEKXZ) already defined in libpqxx.lib(libpqxx.dll) 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "public: bool __thiscall pqxx::result::empty(void)const " (?empty@result@pqxx@@QBE_NXZ) already defined in libpqxx.lib(libpqxx.dll) 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "private: char const * __thiscall pqxx::result:::^)GetValue(unsigned long,unsigned int)const " (?GetValue@result@pqxx@@ABEPBDKI@Z) already defined in libpqxx.lib(libpqxx.dll) 1>libpqxx_staticD.lib(result.obj) : error LNK2005: "private: bool __thiscall pqxx::result::GetIsNull(unsigned long,unsigned int)cons
Would you mind modifying your post? it is breaking forum(it is having 2357 lines).
Prasad MS MVP - VC++
-
Would you mind modifying your post? it is breaking forum(it is having 2357 lines).
Prasad MS MVP - VC++
Ok. I've solved the problem anyway - I simply forget to link to the winsock api
-
by apending more input to my additional dependencies (essentially all my libs, both those of the wrapper and the underlieing api), I get the following linker errors:
1>ibpq.lib(fe-misc.obj) : error LNK2001: unresolved external symbol __imp__select@20 1>libpq.lib(fe-connect.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0 1>libpq.lib(fe-misc.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0 // lots more similar linker errors
What do you think these mean? Regards, Sternocera