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. qmake fails to resolve `pkg-config --cflags opencv`
Forum Updated to NodeBB v4.3 + New Features

qmake fails to resolve `pkg-config --cflags opencv`

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
5 Posts 3 Posters 6.2k Views 2 Watching
  • 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.
  • I Offline
    I Offline
    istvan
    wrote on 20 Apr 2016, 11:40 last edited by
    #1

    In an opencv based project I use pkg-config to find the include and lib path of opencv to maintain portability.
    I added my .pro file the following two lines:

    INCLUDEPATH += `pkg-config --cflags opencv`
    LIBS += `pkg-config --libs opencv`
    

    But it does not build, and the output window shows:

    -I--cflags: unknown option
    

    I went along the build process step-by-step manually, only to find that the generated Makefile contains:

    INCPATH       = -I../Workspace_Qt/untitled4 -I. -I`pkg-config -I--cflags -Iopencv` ... 
    

    And this generates the command in the output window:

    g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../Workspace_Qt/untitled4 -I. **-I`pkg-config -I--cflags -Iopencv` ...
    
    

    ...which is apparently wrong.

    I checked the result of the other pkg-config invocation, to find it is correct:

    LIBS          = $(SUBLIBS) `pkg-config --libs opencv` ...
    

    To reproduce the problem I stripped it and created a new QtWidget project. The problem was the same there.
    I tested it with Qt5.6, Ubuntu 14.04. We tried the .pro files on OSX too, and it behaved the same - though we did not go into details there.

    Is it possible that qmake ignores the ` in the resolution of INCPATH? People use this method all over the web, without any comment. Does anybody have any experience with pkg-config please?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Apr 2016, 21:47 last edited by
      #2

      Hi,

      What about using qmake support for pkg-config ?

      CONFIG += link_pkgconfig
      PKGCONFIG += opencv
      

      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
      • I Offline
        I Offline
        istvan
        wrote on 21 Apr 2016, 10:26 last edited by
        #3

        It works on Linux, but the same .pro file does not work on OSX.
        On OSX we get a
        Project ERROR: opencv development package not found.

        D 1 Reply Last reply 25 Jun 2018, 12:38
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 21 Apr 2016, 11:42 last edited by
          #4

          Where's the opencv.pkg located in on your OS X machine ?

          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
          • I istvan
            21 Apr 2016, 10:26

            It works on Linux, but the same .pro file does not work on OSX.
            On OSX we get a
            Project ERROR: opencv development package not found.

            D Offline
            D Offline
            Denis Trofimov
            wrote on 25 Jun 2018, 12:38 last edited by
            #5

            @istvan I just passed by the answer here: https://stackoverflow.com/a/46794723/7388116
            In the newer version of Qt, this needs to be done to avoid a package not found error:

            QT_CONFIG -= no-pkg-config
            CONFIG += link_pkgconfig
            PKGCONFIG += protobuf #or whatever package here
            

            Also had to do this for Mac:

            mac {
              PKG_CONFIG = /usr/local/bin/pkg-config
            }
            
            1 Reply Last reply
            2

            • Login

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