How to add Qt libraries to visual studio - c++

I have a source with VC++ 2017
I receive the error "Error C1083 Cannot open include file: 'QtCore/QMap': No such file or directory " when i try compile the project.
I download Qt libraries and add to Include project but the problem exist.
Which directory of Qt of i had to add to project to resolve error?
this is header of my code that generate error
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QList>

You need to update your project. Go to the project properties by right-clicking on it in Solution Explorer and then select Properties. Then:
In C/C++->General->Additional Include Directories you must set the Qt installation include path;
In Linker->General->Additional Library Directories you must add the path of .libs files of your qt installation;
In Linker->Input->Additional Dependencies you must put the name of .lib files that you need in order to build the project.
If it's a Qt project, you should also have the Qt plugin installed, in order to work properly with moc and other Qt features.
In alternative (that I suggest) you can create a CMake project and open in in Visual Studio.

Related

how to reference ssleay32.dll in visual studio c++ project

I am new to c++. I have creating a previous copy of the exe application and using the ssleay32.dll and libeay32.dll in visual studio 2017. I have added its path in the C++/General/Include directories and Linker/Input/Additional Dependencies and VC++/Include directories and added the dll in debug folder and current directory. but still cannot figure out what I am doing wrong.
I am unable to include the <openssl/ssl.h> in the cpp file in the project
Any help to fix it?
There is an example on the Microsoft Docs for reference.
project->properties->configuration properties->C/C++->General->Addtional Include Directories->add the path of dll
project->properties->configuration properties->Linker->General->Addtional Library Directories->add the path of dll
project->properties->configuration properties->Linker->Input->Additional Dependencies
For the header file, you could click Project—>Configuration Properties—>C/C++—>General and add the folder path where the .h file is located in the Additional Include Directories.

Visual Studio C++ cannot find OpenCV-Contrib modules

I am trying to use OpenCV multi-target tracker, but cannot include the header files. I have built OpenCV with extra modules by providing the path to opencv_contrib-4.2.0\modules in OPENCV_EXTRA_MODULES_PATH in CMake GUI. However, I cannot include the trackers in the project:
code:
#include <opencv2/tracking.hpp>
error:
cannot open source file "opencv2/tracking.hpp"
code:
#include "samples_utility.hpp"
error:
Cannot open include file: 'samples_utility.hpp': No such file or directory
What should I do to add all the modules of OpenCV-contrib to the default OpenCV directory?
You don't have to add all the modules. Only the modules you need, and in this case the tracking module. You will need to add the corresponding folder to the include directory and the code should compile properly.(your folder might be in different location but the relative path should be the same)
{location_of_opencv_contrib}\modules\tracking\include
{location_of_opencv_contrib}\modules\tracking\samples
For visual studio, you can add the folder path above to Project Properties-> VC++ Directories -> Include Directories
If you are building using gcc, add -I option followed by the directory of the folder mentioned.

how to link Qt with a visual studio c++ application project?

I have Qt 5.12.0 in a folder.
I need to create a dll and/or a bin project that can connect with a QML program.
My problem is that the vs project can't find the Qt files I need.
#include <QGuiApplication>
does not work.
This topic is the continuity of this one
How to link libraries to a project on visual studio? where I shared my problems with linking my dll with my bin project and to link Qt.
So I use a batch file to set the environment variable before launching visual studio. I use these variables to get the path to the Qt include folder, Qt lib etc.
Here is what I tried.
include the directory that contains the headers I need (I guess) :
configuration properties -> C/C++ -> General -> other include directories ->$(QT_INC)/. QT_INC is the path to the include folder. I also tried to write $(QT_INC)/* and $(QT_INC)/QtGui/. In any case,
#include <QGuiApplication>
couldn't compile.
i also added the path to the library folder :
linker->General->Additional library directories->$(QT_LIB)/
and some lib files in :
linker->entry->additionnal dependencies->Qt5Quick.lib;Qt5Gui;lib;Qt5Core.lib
none of these steps creates any error. It just doesn't help to find QGuiApplication.h nor QObject or anything I need.
I know my paths are correct and that using the environment variable like this works as I linked my dll using this method, and because wrong paths generates errors.
How to add Qt to my solution or to a project ?
thanks in advance
It works. The path was incorrect. There were "/" instead of "\" I think. And a synthax error in the batch file.
It's possible to add the header files of Qt by including the path in the properties.
include just the directory include of the Qt folder. Then, include headers again and again until all the errors are gone.
only for QGuiApplication, I need to include this
#include <QtGui/qtguiglobal.h>
#include <QtGui/qcoreapplication.h>
etc. all the includes of the beggining of QGuiApplication.h actually
here is the link to my other post I made about linking Qt to visual studio. How to link libraries to a project on visual studio? The problem was about the path to the dll.

Glew+GLFW Win32 No Dependencies Visual Studio

Is it possible to build and link Glew and GLFW without copying files to the C:??
I can't find any documentation that shows how to use these libraries without copying DLLs to the Visual Studio Directory on the C:.
I just want to include all the .dll and .lib files needed in the directory of my project.
You don't have to put the DLLs in Visual Studio Directory .You can drop those in the Debug or Release (based on your compile mode) folder of your VS project.And you do have to include those DLLs.The rest of setup is rather simple.Right click your project and select "Properties".Include the headers of both libs under C/C++ --> "Additonal Include Directories" . Then : Linker --> "Additional Library Directories" you include the folders containing the lib files.And lastly under Linker-->Input-->"Additional Dependencies" add the names of glew and GLFW libs (glew32.lib , GLFW.lib)And you are ready to go.

Visual studio 2008 Qt Project configuration

I am trying to configure my dll project so that I can access QtCore4.dll and QtGui4.dll functions.
In my project properties under c/c++, Additional Include Directories I have added ...\Qt\4.6.0;
project properties under Linker Additional library directories I have added Qt\4.6.0\lib
Right, so what #include do I need to put in my header files so that I can get the functionality?
Before I was using dependencies and using the includes and but now I have removed the dependencies I am getting a 'cannot open file: 'QtCore/qcoreapplication.h': no such file or directory error.
This project is making me feel like a moron.
Thanks.
Your additional Include directory should be ..\qt\4.6.0\include. If you use qmake or the VS plugin all this is done automatically.
Save yourself time and hassle, get the plugin: http://qt.nokia.com/downloads