include external libraries in qtcreator

1

I need to include external libraries to an application that I have in Qt Creator. In my case I need to include the library xmpp but I do not know how I am new to this idea and I do not have much idea. I read a tutorial online but I did not get it: link

How do I install external libraries in this IDE?

This is the library that I want to add:

    
asked by Perl 19.08.2016 в 12:55
source

1 answer

2

The libraries of or do not" install ". If you have the source code of the library (which seems to be your case) you just have to make the necessary headers (the files .h or .hpp ) be visible from the file in which access is requested, this can be done in two ways:

Absolute route

Assuming you have the file xmpp.h in C:/mis_proyectos/librerias/xmpp/src you can write in the code:

#include "C:/mis_proyectos/librerias/xmpp/src/xmpp.h"

But that is tedious as well as prone to errors (if you change the route you should change the code).

Relative route

Any IDE (Qt Creator included) offers the possibility of configuring some routes from which the headers to be included are searched, Qt uses the QMake system , the QMake file you can edit by hand to add a line like this:

INCLUDEPATH += C:/mis_proyectos/librerias/xmpp/src/

That line will allow you to write in the code:

#include "xmpp.h"

And the IDE will first look for the routes in which the file to be compiled is found and then on all the routes indicated in INCLUDEPATH (it is slightly more complex but this is a simplified explanation)

If editing the QMake file by hand is uncomfortable, you can use the interface to add libraries by clicking secondary on the Projects panel, selecting Add Library and following the instructions.

    
answered by 23.08.2016 в 09:54