PDA

View Full Version : How to include libqxt to use in my project



Cupidvogel
23rd February 2015, 22:05
I am planning to use libqxt to use its emailing service. I downloaded the zip package from here (https://github.com/mnutt/libqxt). As per the README instruction, I first ran qmake, followed by make. Both worked fine. Now I see the lib folder being generated with a number of dynamic libraries and frameworks inside. Which one do I need to use for the emailing bit, as explained here (http://www.qtcentre.org/threads/32359-how-do-i-send-message-by-ÙŽ-QxtSmtp)?

And which header files do I need to include?

wysota
23rd February 2015, 22:51
You need to link with QxtNetwork.

Cupidvogel
23rd February 2015, 22:55
Thanks. Can you tell me how do I do that? There is a QxtNetwork.framework file in my lib folder now, and a QxtNetwork folder in includes, and the folder contains many binaries like QxtSshClient, QxtSshProcess, etc. Which ones do I need to link? And which header files do I need to include?

wysota
24th February 2015, 08:12
Doesn't the readme explain that?

Cupidvogel
24th February 2015, 11:35
Not much. It says this:



1) configure

make sure qmake is in your PATH and run ./configure or configure.bat on windows.

see configure --help for more information

(for msvc you could try ./configure.bat -msvc and open
the solution file in msvc, we recomend compiling on
commandline though)

2) build

type make or nmake when using msvc
then don't forget to make install
Note: This will also install qxt.prf to your qtdir/mkspecs/features directory.



3) use

Add the following lines to your qmake project file:
CONFIG += qxt
QXT += core gui

The QXT variable should contain the modules you want. (In this example core and gui are used.)
Note: Some modules depend on other modules. The required modules are added automatically.

if you have an existing msvc project and can't swtich to qmake you can use zbenjamins solution:

Howto use libqxt in a existing Visual Studio Project:
1. create and install libqxt. (See install instructions)
2. add {libqxtinstalldir}\include\qxt\QxtCore to your include path
3. add {libqxtinstalldir}\lib to your library search path
4. to add a specific libqxt module (f.e QxtSql) you have to:
- add {libqxtinstalldir}\include\qxt\QxtSql to your include path
- add the library QxtSql.lib to your project
Most of the times you have also to include the QxtCore and QxtKit modules.
It's done the same way like the example above.

So I did the first two steps. I tried sudo make install, but it threw an error - cp: cannot stat ‘/Users/Cupidvogel/Desktop/mail/libqxt-master/doc/html/*’: No such file or directory. Anyway now I am left with the folder structure where there are includes, but not libraries. As per the example above, there sould be QxtSql.lib somehwere, can't find it. The lib folder contains QxtSql.framework, no QxtSql.lib..

wysota
24th February 2015, 11:58
To use QXT you need to follow step 3 from the readme. It clearly says what you should do.

Cupidvogel
24th February 2015, 12:02
Yes, it may, as you have already said, and I replied that I tried following it, and even gave my results about where exactly I am stuck. If you don't want to bother helping me, it's totally fine, but please don't continuously say the same thing = 'It is mentioned in step 3'.

wysota
24th February 2015, 12:09
You said you followed the first two steps, so what exactly did you do from step 3?

Cupidvogel
24th February 2015, 12:14
I said that I don't know where the libraries are installed. The lib folder consist of several frameworks, one of which is QxtNetwork.framework. There is no QxtSql.lib library, as mentioned in the MSVC step (even though I am using Mac). However, in the QxtNetwork.framework, if I go inside it, I find a folder called Versions, which contains another folder called Current. Inside that, there is a folder called includes which contains lots of header files, and a QxtNetwork file, which seems to be a binary. In order to follow step 3, modifying the CONFIG and QXT variables, I first need to place the appropriate binaries and dependencies in the right places. What to include, and where to?

wysota
24th February 2015, 12:26
IIn order to follow step 3, modifying the CONFIG and QXT variables, I first need to place the appropriate binaries and dependencies in the right places.

No, you need to modify your CONFIG and QXT variables:


3) use

Add the following lines to your qmake project file:
CONFIG += qxt
QXT += core gui

The QXT variable should contain the modules you want. (In this example core and gui are used.)
Note: Some modules depend on other modules. The required modules are added automatically.

Cupidvogel
24th February 2015, 12:33
Seriously? I will modify CONFIG and QXT in my pro file and it wil magically find where they are located in my HDD? Anyway, I did that. The build ran fine, no error. But I need to use QxtSMTP, so I added network along with core and gui. How do I import QXtSMTP? By just including the source/lib/includes to my project and add that path in the INCLUDEPATH?

wysota
24th February 2015, 13:18
Seriously? I will modify CONFIG and QXT in my pro file and it wil magically find where they are located in my HDD?
Yes, because qxt.prf was copied to your Qt installation directory. Exactly as written in the readme file...


How do I import QXtSMTP?

The docs suggest:


#include <QxtSmtp>


By just including the source/lib/includes to my project and add that path in the INCLUDEPATH?
You don't need to modify INCLUDEPATH. That's what the CONFIG+=qxt thing does.

Cupidvogel
24th February 2015, 13:21
Thanks. The writing to the .prf file failed I guess, for the make install step failed with the message I gave. Any idea on how to fix it? And if this is how it works, then how do I package the code?

For you understanding, we include all libraries and dependent header files in our source/lib folder. The project.pro files specifies that based on platform (say Mac or Windows), the appropriate binaries and header files are copied into the install directory. The binaries which we main in the source/lib are pushed to Git repo through git-fit. Here what do I push then? Where are the libraries and includes which I need to ship?

wysota
24th February 2015, 13:45
The writing to the .prf file failed I guess, for the make install step failed with the message I gave.
The message was that the documentation could not be copied. This has nothing to do with the prf file. You can see if it was copied or not yourself (the readme file lists the location where this file is going to be copied).

Cupidvogel
24th February 2015, 13:51
No, it hasn't been copied. However I do find a qxt.prf file in the features folder in the libqxt-master folder (from where I ran make and configure initially).

wysota
24th February 2015, 13:57
The docs are built by calling "make docs". You can try building them and see if the installation continues when calling make install (remember about write access rights to the target directory).

Cupidvogel
24th February 2015, 13:59
Sigh. I am getting malloc error trap. Is there no other way to do it? That is, by not modifying CONFIG or qxt variables, but by including the necessary libraries and header files in the appropriate path manually?

wysota
24th February 2015, 14:44
Sigh. I am getting malloc error trap.
Where are you getting it? :)


Is there no other way to do it? That is, by not modifying CONFIG or qxt variables, but by including the necessary libraries and header files in the appropriate path manually?
Sure. You can copy whatever is in the prf file to your pro file and adjust all the variables manually. Don't expect my help with that though :)

Cupidvogel
24th February 2015, 14:55
/Users/Cupidvogel/Desktop/mail/libqxt-master/src/core/qxtglobal.cpp:201: Undocumented parameter 'PUB' in QXT_P()
/Users/Cupidvogel/Desktop/mail/libqxt-master/src/core/qxtglobal.cpp:201: No such parameter 'QXT_DECLARE_PUBLIC' in QXT_P()
qdoc3(31442,0x7fff79948300) malloc: *** error for object 0x1109c1a40: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
/bin/sh: line 1: 31442 Abort trap: 6 ( QXT_SOURCE_TREE=/Users/Cupidvogel/Desktop/mail/libqxt-master QXT_BUILD_TREE=/Users/Cupidvogel/Desktop/mail/libqxt-master /Users/Cupidvogel/Desktop/mail/libqxt-master/tools/3rdparty/qdoc3/qdoc3 -DQXT_DOXYGEN_RUN /Users/Cupidvogel/Desktop/mail/libqxt-master/doc/src/qxt.qdocconf )
make: *** [adp_docs] Error 134


The .prf file contains something like this:



contains(QXT, network) {
contains(QXT_MODULES, network):DEFINES += QXT_NETWORK_LIB
else:warning(Qxt was built without QxtNetwork)

DEPENDPATH += $${QXT_INSTALL_HEADERS}/QxtNetwork
INCLUDEPATH += $${QXT_INSTALL_HEADERS}/QxtNetwork
macx:INCLUDEPATH += $${QXT_INSTALL_LIBS}/QxtNetwork.framework/HEADERS/

qtAddLibrary(QxtNetwork)
QXT += core
QT += network
}


Now I can find the $${QXT_INSTALL_LIBS}/QxtNetwork.framework/HEADERS/ and include all header files. By $${QXT_INSTALL_HEADERS}/QxtNetwork, I guess it means the the QxtNetwork folder in includes, which contains lots of header files without .h extension. I opened some of them, all they do is reference the corresponding .h file in
$${QXT_INSTALL_LIBS}/QxtNetwork.framework/HEADERS/, i.e, the QxtJSONRpcClient file in include/QxtNetwork has only one line - "#include "qxtjsonrpcclient.h", and the qxtjsonrpcclient.h file is present in $${QXT_INSTALL_LIBS}/QxtNetwork.framework/HEADERS/.

Where do I get the libraries?

wysota
24th February 2015, 17:41
Within the calls to qtAddLibrary.

Cupidvogel
24th February 2015, 17:42
Umm, meaning?

wysota
24th February 2015, 19:13
Meaning the call adds the given library to the list of libraries to be linked into the project. You can find the code behind that function in one of qmake's feature files somewhere in QTDIR/mkspecs/.

Cupidvogel
25th February 2015, 22:13
I got completely lost. What function to find, and how to build the library?