Skip to content

Instantly share code, notes, and snippets.

@marksteve
Last active April 17, 2024 03:51
Show Gist options
  • Save marksteve/cdd263862d5fcdcdb85c383e3d87cd2e to your computer and use it in GitHub Desktop.
Save marksteve/cdd263862d5fcdcdb85c383e3d87cd2e to your computer and use it in GitHub Desktop.

Building pgModeler in MacOS with Homebrew

The official installation instructions for pgModeler recommends installing Xcode and the Enterprise DB distribution of Postgres to fulfill its build requirements. Luckily, Homebrew's got us covered!

  1. Checkout the source

    git clone https://github.com/pgmodeler/pgmodeler.git
    git checkout main
    
  2. Install dependencies with brew

    brew install postgresql@13 qt@5 libxml2 libpq
    
  3. Tweak build script (pgmodeler.pri)

    macx {
      PGSQL_LIB = /usr/local/opt/libpq/lib/libpq.dylib
      PGSQL_INC = /usr/local/opt/libpq/include
      XML_INC = /usr/local/opt/libxml2/include/libxml2
      XML_LIB = /usr/local/opt/libxml2/lib/libxml2.dylib
      INCLUDEPATH += $$PGSQL_INC $$XML_INC
    }
    

    Brew installs to a different path by default for Apple Silicon devices:

    macx {
      PGSQL_LIB = /opt/homebrew/opt/libpq/lib/libpq.dylib
      PGSQL_INC = /opt/homebrew/opt/libpq/include
      XML_INC = /opt/homebrew/opt/libxml2/include/libxml2
      XML_LIB = /opt/homebrew/opt/libxml2/lib/libxml2.dylib
      INCLUDEPATH += $$PGSQL_INC $$XML_INC
    }
    
  4. Build

    <PATH_TO_QT5_BIN>/qmake -r pgmodeler.pro
    make
    make install
    
@leonardocdz
Copy link

I had to install qt@6 because it wasn't working with qt@5 due to an error I can't recall. But after that it worked for me on Ventura. Thanks!

@sbamin
Copy link

sbamin commented Feb 16, 2024

For macbook pro M2 Max running Sonomia 14.3.1:

prerequisites

brew install postgresql@14 qt@6 libxml2 libpq

Also update XCode from app store, open xcode and accept initial license agreement, and install xcode cli.

update build script, pgmodeler.pri

Add line starting PGSQL_LIB to INCLUDEPATH in a macx { ... } block, preferably second block towards the end of the file provide updated build paths.

macx {
  !defined(PGSQL_LIB, var): PGSQL_LIB = /Library/PostgreSQL/14/lib/libpq.dylib
  !defined(PGSQL_INC, var): PGSQL_INC = /Library/PostgreSQL/14/include
  !defined(XML_INC, var): XML_INC = /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2
  !defined(XML_LIB, var): XML_LIB = /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libxml2.tbd
  INCLUDEPATH += "$$PGSQL_INC" "$$XML_INC"

  PGSQL_LIB = /opt/homebrew/opt/libpq/lib/libpq.dylib
  PGSQL_INC = /opt/homebrew/opt/libpq/include
  XML_INC = /opt/homebrew/opt/libxml2/include/libxml2
  XML_LIB = /opt/homebrew/opt/libxml2/lib/libxml2.dylib
  INCLUDEPATH += $$PGSQL_INC $$XML_INC
}

build

git clone https://github.com/pgmodeler/pgmodeler.git
cd pgmodeler
git checkout main
git pull
git status # should be clean

# workaround for an error:
# Project ERROR: failed to parse default search paths from compiler output
# define xcode path
# https://stackoverflow.com/a/77631382/1243763
which qmake # should be from homebrew install
qmake -r pgmodeler.pro -early QMAKE_DEFAULT_LIBDIRS=$(xcrun -show-sdk-path)/usr/lib
make
make install
echo $?

With a successful install and exit code 0, pgModeler.app should be under /Applications/

@technorior
Copy link

Worked perfectly on m1 pro Sonoma 14.4.1 , thanks 👍👍👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment