When working with the libpq library in C ++ (a library for interacting with the PostgreSQL server), Visual Studio produces the following errors:

testlibpq.o: In function main': testlibpq.o(.text+0x60): undefined reference to PQstatus' testlibpq.o(.text+0xa4): undefined reference to PQerrorMessage '

The official manual says that they may arise because I forgot to add the -lpq parameter. But I did not understand exactly where I should add it. I tried to register it in the properties of the C / C ++ project -> Command line and in Linker -> Command line in additional parameters, but this does not help. I still have little experience using Visual Studio and obviously I just don’t understand something. Can someone at least say about where to prescribe this parameter?

  • Nowhere. This parameter is for the gcc / clang linker. For VC ++, you should get the import library (.lib), add it to Linker -> Input -> Additional dependencies and add the path to the folder where the library is in Linker -> General -> Additional library directories - VTT
  • @VTT In principle, I did. But errors for some reason still appear time after time. - Oleg Danilov

0