Fix .pro file to find QT_HOME



  • My .pro file has the following entries:

        ANDROID_EXTRA_LIBS = \
            $$(QT_HOME)/android_armv7/lib/libQt5Sql.so \
            $$_PRO_FILE_PWD_/libs/android_armv7/libcrypto.so \
            $$_PRO_FILE_PWD_/libs/android_armv7/libssl.so
     }
    

    When I try to build, it fails saying: External library /android_armv7/lib/libQt5Sql.so does not exist!

    I can "fix" this by hacking .pro file to use an absolute path, but clearly this is machine-specific and the wrong way to fix this problem.

        ANDROID_EXTRA_LIBS = \
    -       $$(QT_HOME)/android_armv7/lib/libQt5Sql.so \
    +       /home/gkistner/Qt/5.9.1/android_armv7/lib/libQt5Sql.so \
    

    How/where do I need to set QT_HOME so that the project builds properly for everyone/every system?


  • Lifetime Qt Champion

    Hi,

    AFAIK, the QT += sql ligne should set things up appropriately for you.


  • Qt Champions 2016

    @Phrogz said in Fix .pro file to find QT_HOME:

    How/where do I need to set QT_HOME so that the project builds properly for everyone/every system?

    QT_HOME=/some/path qmake projectname.pro
    

    You're using a syntax specifically tailored for environment variables (obtained when qmake is run). If you don't have that environment variable set, then it will expand to nothing.



  • @kshegunov Can you clarify which path you're referring to? (Path to qmake for Android? Path to the project?) And does it have to be absolute? Ideally the solution would not require any absolute paths (or even relative paths outside the project), since many developers can have the project repo cloned in various locations, and can have Qt installed in various locations.



  • @Phrogz What He is saying that in your pro file to add a new line with

    QT += sql
    

    This will add SQL support and will automatically link to the lib


  • Qt Champions 2016

    @Phrogz said in Fix .pro file to find QT_HOME:

    Can you clarify which path you're referring to?

    I'm referring to the environment variable you're using in your project file -$$(QT_HOME). As other already noted it should be enough for you to specify only the modules you're using and Qt should take care of the rest. I have no knowledge of how Qt was installed and where it resides in your setup, I was explaining what the used syntax does. To make it clear, doing:

    ANDROID_EXTRA_LIBS = /home/gkistner/Qt/5.9.1/android_armv7/lib/libQt5Sql.so
    

    is equivalent to:

    ANDROID_EXTRA_LIBS = $$(QT_HOME)/android_armv7/lib/libQt5Sql.so
    

    when qmake is called with the environment variable QT_HOME set, i.e. calling qmake like this:

    $> QT_HOME=/home/gkistner/Qt/5.9.1 qmake yourprojectfile.pro
    


  • @SGaist Thanks, that did it. Not sure where the offending code in the .pro came from, but adding yours and deleting mine caused things to work without issue.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.