Difference between revisions of "PostgreSQL setup"

From ATI public wiki
Jump to: navigation, search
((by SublimeText.Mediawiker))
 
((by SublimeText.Mediawiker))
 
(4 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.  
# 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'''.
+
##Go to '''Tools->Compiler options->Directories'''.  
# 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'''.
+
##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'''.
 +
# 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>''.
 
# Try compiling.
 
# Try compiling.
 +
 +
Screenshots of the process: http://ati.ttu.ee/~hkinks/iag0582/database/psql-tutorial/

Latest revision as of 00: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/