TomTheGeek

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  pgmodeler.pro]
    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)
      libeay32.dll
      libiconv-2.dll
      libintl-8.dll
      libpq.dll
      ssleay32.dll
    2. QT DLLs (C:\Qt\5.6\mingw49_32\bin\)
      libwinpthread-1.dll
      Qt5Network.dll
      Qt5PrintSupport.dll
    3. XML2
      libxml2.dll
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: ,

4 Comments:

  • Thank you so much for this excellent set of instructions. Got them to work with the 0.9.0 beta and Postgres 9.6 One minor addendum is that I had to copy iconv.dll from PostgreSQL into the final pgmodeler directory at the end to get it to run.

    By Blogger Unknown, at 3:31 PM CDT  

  • Thank you for the tutorial, you really saved my day. I have tested it with pgAdmin 0.9.0 beta2. You need to copy zlib1.dll from C:\PostgreSQL\9.6\bin to C:\pgAdmin to make it work on another computer without having to install PostgreSQL.

    By Blogger Alex Carranza, at 7:41 AM CDT  

  • PgModeler 0.8.2 and PostgreSql 9.6 works fine :)
    Thank you for the tutorial. When I finish I have got problem with start pgModeler. I must copy file C:\Program Files\PostgreSQL\9.6\bin\libconv-2.dll to c:\pgModeler and change name to iconv.dll after this work fine.

    By Anonymous Anonymous, at 6:17 AM CDT  

  • I did everything as you post (windows 10, x64, PG 9.6 x64, pgModeler 0.9.0).
    But got this error:

    C:\pgmodeler-0.9.0>g++ --version
    g++ (GCC) 3.4.5 (mingw-vista special r3)
    Copyright (C) 2004 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


    C:\pgmodeler-0.9.0>qmake PREFIX+=C:/pgModeler -r -spec win32-g++ CONFIG+=release pgmodeler.pro
    Project ERROR: Cannot run compiler 'g++'. Maybe you forgot to setup the environment?

    Any help?

    By Blogger Unknown, at 12:02 PM CDT  

Post a Comment

<< Home