Problems to include QT Liraries - c++

I'm currently learning Qt and I'm having some problems to include libraries to my visual studio project. I have installed the Qt5 libraries with vcpkg and used the command vcpkg integrate install correctly.
In my project I have the following code:
#include <iostream>
#include <QApplication>
using namespace std;
int main(int argc, char* argv[]) {
cout << "hello";
}
Very simple. besides that I have the following configuration in vcpkg properties
Properties vcpkg
And i`m having the following two errors:
Cannot open source file "QApplication"
Cannot open include file qt5/QtWidgets/QApplication: no such file or directory
How can I include the librarie?

Related

Files/directories to include in Visual Studio C++ to use CUDA?

I want to use CUDA/GPU in OpenCV in Visual Studio. For example, cuda::GpuMat. I successfully build OpenCV with the extra modules with CUDA enabled
I tried the following code
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/photo/cuda.hpp>
#include <opencv2/photo.hpp>
using namespace std;
using namespace cv;
int main(){
string imageName("input.bmp");
//CPU version
Mat image = imread(imageName.c_str(), IMREAD_GRAYSCALE);
//CUDA version
cuda::GpuMat imageGPU;
cuda::GpuMat downloadGPU;
Mat buff;
imageGPU.upload(image);
downloadGPU.download(buff);
imwrite("gpu.bmp", buff);
return 0;
}
But I get an unhandled exception error.
I originally downloaded OpenCV in C:\Users\me\Downloads\opencv
I then downloaded and installed the latest OpenCV extra modules with CUDA on in
In Property Pages->C/C++->General->Additional Include Directories, I have:
C:\Users\me\Downloads\opencv\build\include\opencv
C:\Users\me\Downloads\opencv\build\include\opencv2
C:\Users\me\Downloads\opencv\build\include\
In Property Pages->Linker->General->Additional Library Directories, I have:
C:\Users\me\Downloads\opencv\build\x64\vc15\lib
and in Property Pages->Linker->Input->Additional Dependencies, I have:
opencv_world343d.lib
opencv_world343.lib
what else am I supposed to include so I can get GpuMat to work properly?
Most of the cases, yes, but you need to know which library you need to add, it may be cufft.lib, cublas.lib, cudnn.lib, etc. It depends of the function you use inside your code.
Opencv includes a cmake include file that would set all of this up for you if you use cmake to build you VS test project. This file will be in the root of the opencv install directory, i.e. after building opencv running cmake --install or the equivalent in VS. The file is OpenCVConfig.cmake, and it would be included in the CMakeLists.txt file for your project. Then you would call FindPackage(OpenCV), which would locate the OpenCV install, setup a few variables, which you would then use to link against your app.
I can post a sample CMakeList.txt file if you feel that would help.

Cannot open include file: 'QtWidgets/qtwidgetsglobal.h' on vs2017

[Solved]
Additional include directories should be:
C:\Qt\Qt5.9.3\5.9.3\msvc2017_64\include,
not C:\Qt\Qt5.9.3\5.9.3\msvc2017_64\include\QtWidgets
as the statement in qapplication.h is "#include <QtWidgets/qtwidgetsglobal.h>"
When I was running this on VS2017(x86) on win10, I got the error below:
#include <QApplication>
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
return 0;
}
fatal error C1083: Cannot open include file: 'QtWidgets/qtwidgetsglobal.h'
The qtwidgetsglobal.h file is just in the directory, but I don't know why VS can't open it.
It seems that compiler can open QApplication(is it the same as qapplication.h?), but can't open the first #include file 'qtwidgetsglobal.h' in QApplication... Why?
I have set the additional include and lib directories in project settings
Additional include directories :
C:\Qt\Qt5.9.3\5.9.3\msvc2017_64\include\QtWidgets
Additional lib directories:
C:\Qt\Qt5.9.3\5.9.3\msvc2017_64\lib
I have also installed Qt VS Tools and added the qt version
qt vs tools options
I have also tried the 'winrt_x86_msvc2017'directory, and it came to the same error. I can't find 'msvc2017' directory, there's only 'msvc2017_64'.
Any ideas would be appreciated
Additional include directories should be:
C:\Qt\Qt5.9.3\5.9.3\msvc2017_64\include,
not C:\Qt\Qt5.9.3\5.9.3\msvc2017_64\include\QtWidgets
as the statement in qapplication.h is #include <QtWidgets/qtwidgetsglobal.h>

Using Qt to configure OpenCV library failed

I'm new to Qt creator. Yesterday, I followed the official instructions to configure OpenCV library but it failed. I tried everything on the Internet but it just didn't work. Detailed are listed as belows:
test code is simple, I only want to ensure whether the library works:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hello World!" << endl;
return 0;
}
My project configuration is like below :
I thought there might be a problem in debugger. I configure the debugger and I'm quite sure it's ok. The picture is here:
But it just doesn't work. When I click build and run, it says:
C1083: cannot open containing files: "opencv2/opencv.hpp": No such
file or directory.
What's strange is when I include <files> in the editor, the automatic code completion can detect the existence of the OpenCV library and hint after <opencv2/> that there are opencv.hpp, core.hpp .etc. and in the Include Hierarchy, the opencv.hpp exists.
So what might be the problem?

Trouble linking/compiling Libcurl in Eclipse IDE C++ Project

Hi I am having trouble configuring an Eclipse C++ (32bit) project to use libcurl. I am using MinGW. I am on a 64bit windows OS. I have done the following so far:
Add "libcurl.lib" to the project's Libraries
Add the path of libcurl.lib to the Library Paths
Add the path to the curl header files to the Includes path
In source, I included "curl/curl.h"
However, I am seeing the following message:
Info: Internal Builder is used for build
g++ "-LC:\\projectsrc\\Network\\curl-7.34.0-win32\\lib" "-LC:\\projectsrc\\Network\\curl-7.34.0-win32\\dlls" "-LC:\\projectsrc\\Network\\curl-7.34.0-win32\\bin" -o TestLibCurl.exe "src\\TestLibCurl.o" "-lC:\\projectsrc\\Network\\curl-7.34.0-win32\\lib\\libcurl.lib"
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lC:\projectsrc\Network\curl-7.34.0-win32\lib\libcurl.lib
collect2.exe: error: ld returned 1 exit status
Below is the sample source
#include <stdio.h>
#include <curl/curl.h>
#include <curl/easy.h>
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
cout << "test" <<< endl;
return 0;
}
Below is a screenshot of where I added the include path and the library file:
For your reference, I have uploaded my sample C++ eclipse project to dropbox here:
https://www.dropbox.com/s/2jowlkz6qypqe9g/TestingLibCurl.zip
The project file includes main.cpp, the libcurl.lib file, the libcurl header files, and the eclipse project setting files (.cproject, .project, .settings)
Oddly, I am able to get this to work in CodeBlocks IDE, using the same MinGW and using the same computer (Windows 64 bit). Do I need to add linker/options/flags when using Eclipse IDE?

How to link glew in xcode

I can't link glew with xcode. I have glew library is located in /usr/local/lib/libGLEW.dylib
When i compile file in command line all right:
g++ /usr/local/lib/libGLEW.dylib -framework OpenGL main.cpp
But when i compile in xcode, i get error:
'GL/glew.h' file not found
Code:
#include <iostream>
#include <GL/glew.h>
int main(int argc, const char * argv[])
{
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}
Im linked glew with xcode
there screenshot
OS X 10.8.4, Xcode 4.6.1
Adding the library only handles the binary linking. You need to configure Xcode so it can also find the headers describing the contents of the binary.
In Xcode Project Settings search for: Header Search Paths
Add the path to the headers for GLEW (probably near the same folder as the library maybe /usr/local/include). Change the import to match. It should be #include <glew.h> (or #include <GL/glew.h>) if the path gets setup correctly.
For Xcode beginners, here is a screenshot: