Search code examples
macosdebugginghomebrew

How to build library with debug symbols with homebrew?


Does homebrew have any option to build package with debug symbols? I develop an app with QT library and would like to have fast access to its source code from my IDE.

My steps of QT installing:

brew install qt
brew link --force qt
QT_V=`brew info --json=v1 qt | jsawk -n 'out(this.installed[0].version)'` \
  ln -sf /usr/local/Cellar/qt5/${QT_V}/mkspecs /usr/local/mkspecs && \
  ln -sf /usr/local/Cellar/qt5/${QT_V}/plugins /usr/local/plugins

Solution

  • Homebrew doesn’t have such universal option. Run brew info <formula> to get which options are available for a given formula.

    In the case of qt there’s no --debug option:

    $ brew info qt
    ...
    ==> Options
    --with-docs
        Build documentation
    --with-examples
        Build examples
    --with-mysql
        Build with mysql support
    --with-postgresql
        Build with postgresql support
    --with-qtwebkit
        Build with QtWebkit module
    --HEAD
        Install HEAD version
    

    Side note: use brew --prefix <formula> to get a formula’s installed prefix. You’ll get a version-independent prefix if it’s linked:

    $ brew --prefix qt
    /home/baptiste/.linuxbrew/opt/qt
    

    This works across formula upgrades because Homebrew takes care of updating the symlink.