PostgreSQL setup

From ATI public wiki
Revision as of 00:08, 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.
    1. Go to Tools->Compiler options->Directories.
    2. In the Libraries tab add a new directory "C:\PostgreSQL\lib"
    3. In the C Includes tab add a new directory "C:\PostgreSQL\include".
    4. Then in the Tools->Compiler options->General add the -lpq argument in the bottom textbox (can be either one really).
  4. 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.
    1. Extract the zip file.
    2. Navigate to 'bin' folder
    3. Rename libintl3.dll to libintl.dll.
    4. Copy/move libintl.dll and libiconv2.dll both to C:\Windows\System32.
  6. In your C file add #include <libpq-fe.h>.
  7. Try compiling.

Screenshots of the process: http://ati.ttu.ee/~hkinks/iag0582/database/psql-tutorial/