Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qmake for-loop gives empty variable from hand-typed list



  • I am trying to copy some DLL files from folder full of DLL files with similar names. CVLIBS is the list of filenames I want to copy and there are e.g. opencv_core412d.dll and opencv_core412.dll files for "core", same for highgui etc.
    I am getting qmake error "cannot find -lopencv_412d" so it's the LIBS row and LNAME is getting empty string from $$CVLIB. Why?

    CVLIBS = core \
            highgui \
            imgproc \
            videoio \
            video \
            imgcodecs
    
    CONFIG(release, debug|release): DDIR = $$OUT_PWD/release
    else:CONFIG(debug, debug|release): DDIR = $$OUT_PWD/debug
    
    CONFIG(release, debug|release): SUFF = 412
    else:CONFIG(debug, debug|release): SUFF = 412d
    
    ODIR = $$PWD/../../GitHub/opencv/builds/install/x64/vc16/bin
    
    for (CVLIB, CVLIBS)
    {
        LNAME = opencv_$$CVLIB$$SUFF
        LIBS += -L$$ODIR -l$$LNAME
    
        FNAME = $$LNAME.dll
        OFILE = $$BIN/$$FNAME
        DFILE = $$DDIR/$$FNAME
        OFILE ~= s,/,\\,g
        DFILE ~= s,/,\\,g
        QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$OFILE) $$quote($$DFILE) $$escape_expand(\\n\\t)
    }
    
    export(QMAKE_POST_LINK)
    
    INCLUDEPATH += $$PWD/../../GitHub/opencv/builds/install/include
    DEPENDPATH += $$PWD/../../GitHub/opencv/builds/install/include
    

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Your for line is wrong. It should be:

    for (CVLIB, CVLIBS) {
    # Your code here
    }
    

    qmake's syntax is not the same as C++. You have to have the opening bracket on the same line as the test/loop/etc..


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Your for line is wrong. It should be:

    for (CVLIB, CVLIBS) {
    # Your code here
    }
    

    qmake's syntax is not the same as C++. You have to have the opening bracket on the same line as the test/loop/etc..


Log in to reply