Adding all external libraries stored from a directory into Qt project
c++, qmake, qt, shared-libraries, wildcard
Solution
You can use the files, basename and replace functions to get what you need:
LIBS *= -L$$PWD/MYLIBS
win32 {
SHARED_LIB_FILES = $$files($$PWD/MYLIBS/*.dll)
for(FILE, SHARED_LIB_FILES) {
BASENAME = $$basename(FILE)
LIBS += -l$$replace(BASENAME,.dll,)
}
}
unix {
SHARED_LIB_FILES = $$files($$PWD/MYLIBS/*.so)
for(FILE, SHARED_LIB_FILES) {
BASENAME = $$basename(FILE)
LIBS += -l$$replace(BASENAME,.so,)
}
}
Problem
Is there a way to add all libraries from a given folder without adding every single one to the `LIBS` variable in Qt project file. I've put all libraries (DLLs (win) or SOs (unix)) in one directory (MYLIBS) along with header files and tried something like this: ``` LIBS *= -L$$PWD/MYLIBS -l* INCLUDEPATH += $$PWD/MYLIBS DEPENDPATH += $$PWD/MYLIBS ``` It didn't work with error message `cannot find -l*`. Is it possible for `qmake` to use the wildcards while creating Makefiles?