Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a static library in Qt Creator

I'm having a hell of a time finding documentation which clearly explains how to use a static library in Qt Creator.

I've created and compiled my static library using Qt Creator (New=>Projects\C++ Library=>Set type to "Statically Linked Library"). It compiles and spits out a ".a file".

The problem I encounter is when I try to use the library. I have another project that would like to use it (#include files in the library, etc) but I don't know the proper way to link with the library or include files from the library.

like image 791
Dan O Avatar asked Sep 01 '09 08:09

Dan O


People also ask

Is Qt dynamically linked?

Qt uses dynamic linking by default. You'll notice this immediately during deployment to a non-developer machine, because your code will not run without the Qt libraries. If your concern is the LGPL, just be careful when compiling Qt itself.

Is Qt Creator an IDE?

Qt Creator is a cross-platform integrated development environment (IDE) built for the maximum developer experience. Qt Creator runs on Windows, Linux, and macOS desktop operating systems and allows developers to create software across desktop, mobile, and embedded platforms.


2 Answers

LIBS += -L[path to lib] -l[name of lib] 

Note! that filename of lib: lib[nameOfLib].a and you have to pass only original part -l[nameOfLib]

like image 60
Dewfy Avatar answered Sep 19 '22 09:09

Dewfy


..from QT project creator

  1. goto projectName.pro from left hand side menu
  2. type LIBS +=
  3. rightClick AddLibrary
like image 29
Cavalieri Giovanni Avatar answered Sep 19 '22 09:09

Cavalieri Giovanni