PostgreSQL setup

From ATI public wiki
Revision as of 00:38, 17 May 2016 by Hkinks (Talk) ((by SublimeText.Mediawiker))

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Windows

This tutorial will walk you through the steps of how you can set up the PostgreSQL environment with necessary libpsql libraries needed to connect to PostgreSQL database with C.

  1. First step is to go to http://www.enterprisedb.com/products-services-training/pgdownload#windows and download the corresponding PostgreSQL installation for your system. Assuming 64 bit from further on.
  2. Install PostgreSQL into C:\PostgreSQL. (Can be anywhere, however Dev-Cpp does not seem to work well with paths that have spaces.)
  3. Assuming you are using Dev-Cpp, you now have to add the library and included directory paths to the IDE. Go to Tools->Compiler options->Directories. In the Libraries tab add a new directory "C:\PostgreSQL\lib" and in the C Includes tab add a new directory "C:\PostgreSQL\include". Then in the Tools->Compiler options->General add the -lpq argument in the bottom textbox (can be either one really).
  4. Now the compilation should work, however when you run your application, it should give you an error about libpq.dll being missing. To fix that copy libpq.dll file from the PostgreSQL installation directory (C:\PostgreSQL\lib\libpq.dll) to C:\Windows\System32.
  5. Go to http://gnuwin32.sourceforge.net/downlinks/make-dep-zip.php and download the zip file. Extract and in there you should find 'bin' folder with two files inside: libiconv2.dll and libintl3.dll. Rename libintl3.dll to libintl.dll. Copy/move them both to C:\Windows\System32.
  6. Try compiling.