Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt - QMAKE_LIBDIR vs LIBS

Tags:

qt

qmake

One can find a lot of examples where QMAKE_LIBDIR is used to specify additional library directories.

The Qt manual says:

QMAKE_LIBDIR

Specifies a list of system library paths. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

Up to now I always used "unix: -L$$(LIB_DIR) -l" or similar whenever I wanted to use an external library in one of my projects and didn't want to use the library wizard.

Can I conclude that specifying a path via -L is discouraged even if there is no corresponding statement within the manual? (According to this post it is discouraged - but why?)

Thanks in advance.

like image 386
Apollo13 Avatar asked Jul 01 '14 13:07

Apollo13


People also ask

How do you qmake in Qt?

Building a Project For simple projects, you only need to run qmake in the top level directory of your project to generate a Makefile. You can then run your platform's make tool to build the project according to the Makefile.

What is $$ PWD?

pwd stands for Print Working Directory. It prints the path of the working directory, starting from the root. pwd is shell built-in command(pwd) or an actual binary(/bin/pwd). $PWD is an environment variable which stores the path of the current directory.

What is CMake and qmake?

CMake is an alternative to qmake for automating the generation of build configurations. Setting Up Qbs. Qbs is an all-in-one build tool that generates a build graph from a high-level project description (like qmake or CMake do) and executes the commands in the low-level build graph (like make does).


1 Answers

In a way there's a corresponding statement. Put your -Lpath/to/dir into the LIBS variable:

http://doc.qt.io/qt-5/qmake-variable-reference.html#libs

LIBS

Specifies a list of libraries to be linked into the project. If you use the Unix -l (library) and -L (library path) flags, qmake handles the libraries correctly on Windows (that is, passes the full path of the library to the linker). The library must exist for qmake to find the directory where a -l lib is located.

For example:

unix:LIBS += -L/usr/local/lib -lmath

win32:LIBS += c:/mylibs/math.lib

So, using -L within LIBS is actually encouraged by the Qt docs

like image 135
DomTomCat Avatar answered Oct 01 '22 00:10

DomTomCat