Difference between revisions of "PostgreSQL setup"

From ATI public wiki
Jump to: navigation, search
((by SublimeText.Mediawiker))
((by SublimeText.Mediawiker))
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
# 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.
 
# 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.
 
# Install PostgreSQL into C:\PostgreSQL. (Can be anywhere, however Dev-Cpp does not seem to work well with paths that have spaces.)
 
# Install PostgreSQL into C:\PostgreSQL. (Can be anywhere, however Dev-Cpp does not seem to work well with paths that have spaces.)
# 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).
+
# 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'''"
 +
##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).
 
# Copy libpq.dll file from the PostgreSQL installation directory ('''C:\PostgreSQL\lib\libpq.dll''') to '''C:\Windows\System32'''.
 
# Copy libpq.dll file from the PostgreSQL installation directory ('''C:\PostgreSQL\lib\libpq.dll''') to '''C:\Windows\System32'''.
# 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'''.
+
# Go to http://gnuwin32.sourceforge.net/downlinks/make-dep-zip.php and download the zip file.  
 +
## Extract the zip file.
 +
## Navigate to 'bin' folder
 +
## Rename libintl3.dll to '''libintl.dll'''.  
 +
## Copy/move '''libintl.dll''' and '''libiconv2.dll''' both to '''C:\Windows\System32'''.
 
# In your C file add ''#include <libpq-fe.h>''.
 
# In your C file add ''#include <libpq-fe.h>''.
 
# Try compiling.
 
# Try compiling.
  
{| class="wikitable"
+
Screenshots of the process: http://ati.ttu.ee/~hkinks/iag0582/database/psql-tutorial/
| [[http://ati.ttu.ee/~hkinks/iag0582/database/1.png|50px|link=]]
+
| [[http://ati.ttu.ee/~hkinks/iag0582/database/2.png|50px|link=]]
+
| [[http://ati.ttu.ee/~hkinks/iag0582/database/3.png|50px|link=]]
+
| [[http://ati.ttu.ee/~hkinks/iag0582/database/4.png|50px|link=]]
+
| [[http://ati.ttu.ee/~hkinks/iag0582/database/5.png|50px|link=]]
+
| [[http://ati.ttu.ee/~hkinks/iag0582/database/6.png|50px|link=]]
+
| [[http://ati.ttu.ee/~hkinks/iag0582/database/7.png|50px|link=]]
+
| [[http://ati.ttu.ee/~hkinks/iag0582/database/8.png|50px|link=]]
+
| [[http://ati.ttu.ee/~hkinks/iag0582/database/9.png|50px|link=]]
+
|}
+

Latest revision as of 01:08, 17 May 2016

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/