Linking and using libpq with Visual C ++ Express 2010

I am trying to access from a Visual C ++ 2010 Express Postgres database. I have both on my machine, but SQL calls do not work at all. I searched a lot of sites. I think this Express version does not have default connections, such as the non-express version (especially Visual C ++ 2008).

The only thing I could find was the following link, and I am following the changes in the properties area of ​​the Visual C ++ Express project.

http://www.askyb.com/cpp/c-postgresql-example/

When I try to run C ++ code on this website, I get errors indicating that it cannot find the functions.

Do you have any idea what I'm doing wrong? Would it be better for me to use something other than Visual C ++ Express 2010 to connect to postgres db? One of the other versions of Express? Plain (non-express) Visual C ++?

thanks

+4
source share
3 answers

You may also be interested in libpqtypes and libpqxx if you work with PostgreSQL and libpq. The former provides significantly simplified access to data values ​​from libpq, while the latter provides a more convenient interface for C ++.

As for errors, most likely:

  • Your path to the path of the path or path of the link library is incorrect if it does not work at compile time or link time; or
  • Your PATH does not include libpq if it does not work at runtime.
+2
source

Most likely (you did not specify any error messages), the problem is in your setup. You need to add the correct directory ("include") of the directory and library; if you just copied them from some tutorial, make sure that they actually point to the real place where these files are located (.h and .lib files).

+1
source

You need to recompile libpq using MSVC (nmake / f win32.mak all), after which you need to configure the project to use this library and change the support for Common Language Runtime Support (/ clr), and not CLR / clean.

+1
source

Source: https://habr.com/ru/post/1435562/


All Articles