Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator cannot find libraries installed by Homebrew via pkg-config
QtWS25 Last Chance

Qt Creator cannot find libraries installed by Homebrew via pkg-config

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
8 Posts 3 Posters 6.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jmaibaum
    wrote on 19 Jan 2016, 17:06 last edited by jmaibaum
    #1

    Hi,

    I have installed the latest Qt 5.5.1 (released 2015-10-13) from the official installer on my Mac (10.11.2) and I want to use external libraries in my project, for instance libsndfile, which I have installed via Homebrew.

    When running pkg-config --libs sndfile manually from the Terminal, it returns -L/usr/local/Cellar/libsndfile/1.0.26/lib -lsndfile, so everything seems to be in the right place.

    I then tried to add libsndfile to my qmake project file, as specified in the docs, choosing the “System package” option, and entering sndfilein the prompt on the following page in the wizard, resulting in the following two lines being added to my project file:

    unix: CONFIG += link_pkgconfig
    unix: PKGCONFIG += sndfile
    

    But now, Qt Creator complains:

    Project ERROR: sndfile development package not found
    

    and i cannot compile my project any more.

    As a sidenote, the same project file compiles fine on an Arch Linux machine with libsndfile installed as a normal system library from their official repository.

    I found that there was a bug with Qt Creator and pkg-config libraries on Mac OSX. But a fix for this seems to be merged with the 5.5 line since 2015-09-28. So it should be part of my version (see above?), right?

    I've also tried the solutions suggested in a stack overflow question without success. I can hit the green compile buttons again in Qt Creator after adding QT_CONFIG -= no-pkg-config to my project file, but I still get a sndfile development package not found error, even after tinkering with /etc/launchd.conf or /etc/paths.d/local to add /usr/local/bin to my PATH (and re-launching Qt Creator afterwards).

    What am I doing wrong? Is it somehow possible to use libraries installed via Homebrew on a Mac?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 Jan 2016, 21:26 last edited by
      #2

      Hi,

      Where are the pkg-config files from Homebrew located ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jmaibaum
        wrote on 19 Jan 2016, 22:17 last edited by
        #3

        The actual files reside in /usr/local/Cellar/<package_name>/<package_version>/lib/pkgconfig/<package name>.pc and those files get symlinked to /usr/local/lib/pkgconfig/<package_name>.pc. So, in case of libsndfile, it's:

        /usr/local/lib/pkgconfig/sndfile.pc -> /usr/local/Cellar/libsndfile/1.0.26/lib/pkgconfig/sndfile.pc.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 19 Jan 2016, 22:53 last edited by
          #4

          You may need to set the PKG_CONFIG_PATH environment variable in your build environment for pkg-config to search there and find your brew installed libraries.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jmaibaum
            wrote on 21 Jan 2016, 09:55 last edited by
            #5

            Hmm, adding /usr/local/lib/pkgconfig as PKG_CONFIG_PATH to the Build Environment for my project did not help. But adding /usr/local/bin to the PATH of my build environment seems to do the trick. I saw that it was missing from there, so I gave it a try.

            I am not sure where to go from here. Is there a portable way to alter the build environment from the project file? I tried something like mac: PATH += /usr/local/bin but that did not work. So do changes like this always have to be altered manually in the Project Settings in Qt Creator?

            Perhaps using Homebrew for installing external libraries on OSX is not the best solution with Qt Creator?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 21 Jan 2016, 11:43 last edited by
              #6

              Do you mean that pkg-config wasn't found when running Qt Creator ?

              If so, then the usual trick to modify PATH in your .profile or .bash_rc will make it work from the command line but not for the application you start from e.g. Spotlight or by clicking on them. IIRC you can add a path to /etc/paths.d/mypath to make it system wide

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • J Offline
                J Offline
                jmaibaum
                wrote on 3 Feb 2016, 09:05 last edited by
                #7

                Ok, thanks. That makes it clear for me now.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mb79
                  wrote on 6 Mar 2020, 13:02 last edited by
                  #8

                  Can you please share the solution? I am facing the exact same problem, but with gstreamer-1.0, as I posted here: https://forum.qt.io/topic/112301/gstreamer-1-0-not-found-on-mac

                  Thanks!

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved