Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Link2005 error when attempting to build project in visual studio IDE that uses libpqxx C++ wrapper for the libpq C API in visual studio

Link2005 error when attempting to build project in visual studio IDE that uses libpqxx C++ wrapper for the libpq C API in visual studio

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiocsharppostgresqlcom
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sternocera
    wrote on last edited by
    #1

    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

    M P 2 Replies Last reply
    0
    • S 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

      M Offline
      M Offline
      Maxwell Chen
      wrote on last edited by
      #2

      Did you configure the Project properties for Linker --> Input --> Additional Dependencies. ?


      Maxwell Chen

      S 2 Replies Last reply
      0
      • M Maxwell Chen

        Did you configure the Project properties for Linker --> Input --> Additional Dependencies. ?


        Maxwell Chen

        S Offline
        S Offline
        Sternocera
        wrote on last edited by
        #3

        Yes. I've just added libpqxx.lib, per the instructions in the readme file, Regards, Sternocera

        S 1 Reply Last reply
        0
        • S Sternocera

          Yes. I've just added libpqxx.lib, per the instructions in the readme file, Regards, Sternocera

          S Offline
          S Offline
          Sternocera
          wrote on last edited by
          #4

          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!

          1 Reply Last reply
          0
          • M Maxwell Chen

            Did you configure the Project properties for Linker --> Input --> Additional Dependencies. ?


            Maxwell Chen

            S Offline
            S Offline
            Sternocera
            wrote on last edited by
            #5

            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

            S 1 Reply Last reply
            0
            • S 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

              P Offline
              P Offline
              prasad_som
              wrote on last edited by
              #6

              Would you mind modifying your post? it is breaking forum(it is having 2357 lines).


              Prasad MS MVP -  VC++

              S 1 Reply Last reply
              0
              • P prasad_som

                Would you mind modifying your post? it is breaking forum(it is having 2357 lines).


                Prasad MS MVP -  VC++

                S Offline
                S Offline
                Sternocera
                wrote on last edited by
                #7

                Ok. I've solved the problem anyway - I simply forget to link to the winsock api

                1 Reply Last reply
                0
                • S Sternocera

                  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

                  S Offline
                  S Offline
                  Steve S
                  wrote on last edited by
                  #8

                  That you have not specified ws2_32.lib as a dependency :) They are routines from the WinSock library.

                  Steve S Developer for hire

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups