How do i reference the qjson.dll file from my qt project? - qt

How do I refernce the qjson.dll file from one of qt project?
For eg :C:\qjson-0.7.1\qjson\build\lib , in this location, I have qjson.dll and qjson.dll.a file. I want to use that dll from my qt project.How should I point to that location in that .pro file. I can't compile successful, the error that I got is
C:/QTTest/foo/foo/main.cpp:6: error: Qjson/parser.h: No such file or directory .Can someone can help me?
Thx.

First, you have to tell QMake in your .pro where is located your header files using the INCLUDEPATH variable (please correct the path to point the location of your Qjson folder):
INCLUDEPATH += "c:/qjson-0.7.1/include"
Second, you must specify your library and it's location using LIBS variable:
LIBS += "c:/qjson-0.7.1/qjson/build/lib/qjson.dll.a"
Now, QMake will find your header file and your library. You will need to have the qjson.dll in the same directory as your Qt application or to add it's location in your PATH environment variable.

Related

If you include a .pri, shouldn't that .pri's include path affect your #includes?

If I include(someOtherProject.pri) in my .pro, and that other project file (.pri) has INCLUDEPATH += . in it, then shouldn't my files in my .pro find those headers when I #include them? I cleaned and ran qmake on everything, regenerated the .pri file by simply copying the .pro from that other project and renaming it with the .pri extension, but when I #include a file from that other project, compiler says it cannot find it.
I wouldn't expect that I must also edit the INCLUDEPATH of my working .pro file if I am already using include(someOtherProject.pri) -- that would make the point of using include(someOtherProject.pri) unnecessary altogether.
The solution is to have INCLUDE PATH += $$PWD/ in the .pri instead, as this will expand out to the proper hard-coded path no matter where it is included.

Qt Error: cannot open include file: 'opencv2/core/core.hpp' no such file or directory

I want to build an opencv project using Qt 5.1_VS2010. I have included the path for opencv include files. But when I run the code, I get the error that specific .hpp file does not exist! I have checked in the directory and it actually exists there! another point that when I was trying to include it in my main c++ file, the auto completion guide actually helped me complete the whole path! so it means the directory and the header file was already recognized! anyway, part of my .pro file that includes the path is like this:
INCLUDEPATH += "C:/opencv/build/include"

QtCreator tricky project

I have a project in Qt Creator which has several shared library projects and the main project which also contains the main function. What I want is to add a new project which shouldn't be a shared library but just a project with some header files where I keep definitions and error codes. What I wish is to be able to add the path of this project to other projects INCLUDEPATH in order to use those files in other projects.
To do so I created an empty project which .pro file looks like this:
HEADERS += \
myHeader.h
but when I build the whole project it complains that it doesn't find the main in this project with only one header.
Is it possible in QtCreator to achieve this?
Create a .pri file which has your INCLUDEPATH, etc; and then refer to it in your other projects' .pro files:
# Common.pri
INCLUDEPATH += ../myPath
INCLUDE += myHeader.h
# OtherProject.pro
!include( ./Common.pri ) {
error( Could not find the Common.pri file. )
}
INCLUDEPATH += ../myOtherPath
Remember to use the += operator in your .pro files otherwise they will overwrite the .pri file variables.

Adding each subdirectory's path to qt pro file variable

I want to add path of each subdir having .h file to a qt pro file variable
I found this http://doc.qt.digia.com/qt/qmake-project-files.html#built-in-functions-and-control-flow for use of a for loop but don know how to use if to do above task.
INCLUDEPATH +=$$(MITK_INCLUDE_PATH)
When I wrote this (where path variable having only outer dir's path) its allowing me to include a header in source as:
> #include"ITK-src/Code/BasicFilters/itkAbsImageFilter.h"
and qmake is running properly but when I am building this project its asking for another .h on which above .h depend. Before this I have worked with adding 3'rd party libs in which I gave path of each header file's location to INCLUDEPATH as here but if there is any other way I want to know possibility.

Adding QtLua to a QtCreator project

Well i have a folder called libqtlua-1.4 in which i have the libqtlua.so, the qtlua executable, and in libqtlua-1.4/src/QtLua i have the headers.
How can i include it in a qtcreator project?
(I am running in ubuntu 11.10)
Any suggestion would be appreciated.
You have to specify the library in you project file (file with .pro extension) to qmake be able to see them when compile:
LIBS += -L/path/to/your/lib/libqtlua-1.4 -lqtlua
INCLUDEPATH += /path/to/your/lib/libqtlua-1.4/src/QtLua
References: LIBS, INCLUDEPATH.

Resources