All the geeky stuff that gets me hot.

Monday, June 27, 2016

How to compile pgModeler 8.2 for Win7 and PostgeSQL 9.5

pgModeler is a great tool for creating PostgreSQL queries but the documentation on compiling for Windows is old and incomplete. Here are the steps I took to compile it on Windows 7. All software is 32bit as QT does not support x64 on Windows.
  1.  Install PostgreSQL server. (I installed to C:\Program Files (x86)\PostgreSQL\9.5)
  2.  Install QT framework (C:\Qt)
  3.  Download the XML2 Library and  (C:\Program Files (x86)\libxml2\) and copy libxml2.lib to (C:\Program Files (x86)\PostgreSQL\9.5\lib)
  4. Install MiniGW. Download mingw-get-setup.exe and run, then select:
    • minigw-developer-toolkit
    • minigw-gcc-v3-g++
    • the 4 minigw32-gcc-g++ packages (bin, dev, doc, man)
  5. Add to PATH environment variable (adjust paths as required)
       C:\Program Files (x86)\PostgreSQL\9.5\bin\;C:\MinGW\bin\;C:\Qt\5.6\mingw49_32\bin\
  6. Download pgModeler source code. Unzip to C:\pgmodeler-8.2.0\
  7.  Edit pgmodeler.pri and add above the Windows section (adjust paths as required):
    • PGSQL_LIB = "C:/Program Files (x86)/PostgreSQL/9.5/lib/libpq.dll"
    • PGSQL_INC = "C:/Program Files (x86)/PostgreSQL/9.5/include/"
    • XML_INC = "C:/Program Files (x86)/libxml2-2.7.8.win32/include"
    • XML_LIB = "C:/Program Files (x86)/libxml2-2.7.8.win32/bin/libxml2.dll" 
  8. Make directory C:\pgModeler\
  9. Open a command prompt then change to the source code directory [CD C:\pgmodeler-8.2.0\]
  10. Run: [qmake PREFIX+=C:/pgModeler -r  -spec win32-g++ CONFIG+=release]
    This configures the project files
  11. Run: [mingw32-make -j5] to compile the project
  12. Run: [mingw32-make install] to move the compiled files into C:\pgModeler\
  13. Run: [CD C:\pgModeler]
  14. Run: [windeployqt pgmodeler.exe] to copy the QT files to the program directory
  15. Now copy these DLLs to C:\pgModeler
    1. PostgreSQL DLLs  (PostgreSQL\9.5\bin)
    2. QT DLLs (C:\Qt\5.6\mingw49_32\bin\)
    3. XML2
C:\pgModeler will now contain all the files needed to run pgModeler. You can ZIP this folder and copy to C:\pgModeler on any computer where the program is needed. Ideally we could run this from %LOCALAPPDATA% but I could not figure out how to compile with that as the PREFIX. So it's hardcoded to C:\pgModeler instead.

Labels: ,