Read Mat Files in C++ in a Qt project - c++

I am trying to read a mat-file in an own mat_file_read.cpp in a Qt project, and I am having problems. My error:
error lnk2019: unresolved external symbol matOpen referenced in function "int __cdecl read_mat_file(class QString)" (?read_mat_file##YAHVQString###Z)"
In my project.pro, I am including:
INCLUDEPATH += C:\Program Files\MATLAB\MATLAB Production Server\R2015a\extern\include\
LIBS += -LC:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64
-llibmx
-llibmat
-llibeng
In the header of my cpp file:
#include <stdio.h>
#include <stdlib.h>
#include "mat.h"
#include "matrix.h"
#include <QString>
#include <QFileDialog>
In my mat_file_reader.cpp:
#include "read_mat_file.h"
int read_mat_file(QString file)
{
// Variable definition
int result;
MATFile *pmat;
if (file.isEmpty()) return 0;
QByteArray ba = file.toLatin1();
const char *rootFile = ba.data();
pmat = matOpen(rootFile,"r");
result = 0;
return (result==0)?EXIT_SUCCESS:EXIT_FAILURE;
}
And the curious thing is the Qt editor is recognizing the functions from "mat.h". It is suggesting me the functions....
Thanks so much in advance.

I think maybe it's because you forget your \ in the end of your lines.
And also, maybe you need to avoid having spaces in your path, or try putting it in $$quote(), like the following:
INCLUDEPATH += $$quote(C:/Program Files/MATLAB/MATLAB Production Server/R2015a/extern/include)
LIBS += -L$$quote(C:/Program Files/MATLAB/MATLAB Production Server/R2015a/bin/win64) \
-llibmx \
-llibmat \
-llibeng

Finally I found a solution, although I don't understand fine why.... I only changed the next lines in my project.pro of Qt:
INCLUDEPATH += C:\Program Files\MATLAB\MATLAB Production Server\R2015a\extern\include\
LIBS += -llibmx -LC:\librerias\matlab\extern\lib\win64\microsoft
LIBS += -llibmat -LC:\librerias\matlab\extern\lib\win64\microsoft
LIBS += -llibeng -LC:\librerias\matlab\extern\lib\win64\microsoft
Now it is working.... It's strange I think, but for me It's ok. :)
Thanks so much #Suever for the support.

Related

Qt + Ogre3D. I cannot build a very simple example

I use:
Qt 5.15.2 MinGW 32-bit Dynamic for Debug build
Ogre 13.1.1 MinGW Static build
There is a class called ApplicationContextQt that can help to use Qt with Ogre3D but I have errors:
This example is very simple:
main.cpp
#include "Ogre.h"
#include "OgreApplicationContextQt.h"
#include <QGuiApplication>
class MyTestApp : public OgreBites::ApplicationContextQt, public OgreBites::InputListener
{
public:
MyTestApp();
void setup();
bool keyPressed(const OgreBites::KeyboardEvent& evt);
};
MyTestApp::MyTestApp() : OgreBites::ApplicationContextQt("OgreTutorialApp")
{
}
bool MyTestApp::keyPressed(const OgreBites::KeyboardEvent& evt)
{
if (evt.keysym.sym == OgreBites::SDLK_ESCAPE)
{
getRoot()->queueEndRendering();
}
return true;
}
void MyTestApp::setup(void)
{
// do not forget to call the base first
OgreBites::ApplicationContextQt::setup();
}
int main(int argc, char *argv[])
{
QGuiApplication qapp(argc, argv);
MyTestApp app;
app.initApp();
app.getRoot()->startRendering();
app.closeApp();
return qapp.exec();
}
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE"
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\Bites"
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\RTShaderSystem"
LIBS += -L"E:\ProgramFiles\ogre-13.1.1\lib"
LIBS += -L"E:\ProgramFiles\ogre-13.1.1\lib\OGRE"
LIBS += -lOgreBitesQtStatic
LIBS += -lOgreBitesStatic -lRenderSystem_GL3PlusStatic -lOgreGLSupportStatic -lOgreMeshLodGeneratorStatic -lOgreOverlayStatic -lOgrePagingStatic -lOgrePropertyStatic -lOgreRTShaderSystemStatic -lOgreVolumeStatic -lPlugin_BSPSceneManagerStatic -lPlugin_DotSceneStatic -lPlugin_OctreeSceneManagerStatic -lPlugin_OctreeZoneStatic -lPlugin_ParticleFXStatic -lPlugin_PCZSceneManagerStatic -lRenderSystem_GLES2Static -lRenderSystem_GLStatic -lOgreMainStatic -lOgreTerrainStatic -lCodec_STBIStatic -lzlibstatic
LIBS += -lSDL2main -lSDL2.dll -lfreetype -lpugixml
LIBS += -lopengl32 -lgdi32
You can try this one ?
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE"
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\Bites"
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\RTShaderSystem"
DEPENDPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE"
DEPENDPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\Bites"
DEPENDPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\RTShaderSystem"
LIBS += -L"E:/ProgramFiles/ogre-13.1.1/lib/OgreBitesQtStatic" -lOgreBitesQtStatic
LIBS += -L"E:/ProgramFiles/ogre-13.1.1/lib/OGRE" -lOgreBitesStatic
// OR ...
LIBS += "E:/ProgramFiles/ogre-13.1.1/lib/OgreBitesQtStatic/OgreBitesQtStatic.a"
LIBS += "E:/ProgramFiles/ogre-13.1.1/lib/OGRE/OgreBitesStatic.a"
// It just depends on the actual names of your libraries
// Same for the others unless their file location is decleared under system path.
// If so, you can add that libraries like how you did with opengl
And it is nice to add PRE_TARGETDEPS macros too if you make changes on those libraries so often:
PRE_TARGETDEPS += "E:/ProgramFiles/ogre-13.1.1/lib/OgreBitesQtStatic.a"
You can replace "/"s with "" too.
And the problem with your pro file was: You added library paths as libraries. And then tried to add that libraries from system environment.

Error when trying to build project with included Qt class library library

I have created Qt class library with Qt VS Tools for visual studio 2019.
I included this library to my Qt project that I too made with Qt VS tools,
but now my project won't build.
That is .pro file of my project:
# ----------------------------------------------------
# This file is generated by the Qt Visual Studio Tools.
# ------------------------------------------------------
TEMPLATE = app
TARGET = JanturiolGameServer
DESTDIR = ./Win32/Debug
QT += core network gui widgets networkauth
CONFIG += debug
DEFINES += _UNICODE _ENABLE_EXTENDED_ALIGNED_STORAGE WIN64 QT_DLL QT_NETWORK_LIB QT_NETWORKAUTH_LIB QT_WIDGETS_LIB
INCLUDEPATH += ../../JanturiolLib \
./GeneratedFiles \
. \
./GeneratedFiles/$(ConfigurationName)
LIBS += -L"../../JanturiolLib"
DEPENDPATH += .
MOC_DIR += ./GeneratedFiles/$(ConfigurationName)
OBJECTS_DIR += debug
UI_DIR += ./GeneratedFiles
RCC_DIR += ./GeneratedFiles
include(JanturiolGameServer.pri)
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../JanturiolLib/Win32/release/ -lJanturiolLib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../JanturiolLib/Win32/debug/ -lJanturiolLib
else:unix: LIBS += -L$$PWD/../JanturiolLib/Win32/ -lJanturiolLib
INCLUDEPATH += $$PWD/../JanturiolLib
DEPENDPATH += $$PWD/../JanturiolLib
That is .pro file of my library:
# ----------------------------------------------------
# This file is generated by the Qt Visual Studio Tools.
# ------------------------------------------------------
TEMPLATE = lib
TARGET = JanturiolLib
DESTDIR = ./Win32/Release
QT += core xml network gui uitools widgets networkauth
CONFIG += release
DEFINES += _UNICODE _ENABLE_EXTENDED_ALIGNED_STORAGE WIN64 QT_DLL QT_NETWORK_LIB QT_NETWORKAUTH_LIB QT_UITOOLS_LIB QT_WIDGETS_LIB QT_XML_LIB JANTURIOLLIB_LIB
INCLUDEPATH += ./GeneratedFiles \
. \
./GeneratedFiles/$(ConfigurationName)
DEPENDPATH += .
MOC_DIR += ./GeneratedFiles/$(ConfigurationName)
OBJECTS_DIR += release
UI_DIR += ./GeneratedFiles
RCC_DIR += ./GeneratedFiles
include(JanturiolLib.pri)
That is PlayerChracter.h:
#pragma once
#include "BaseCharacter.h"
#include <string>
enum CharacterClass{warrior, mage, ranger};
//position
struct Pos
{
int xPos;
int yPos;
};
class PlayerCharacter : public BaseCharacter
{
public:
PlayerCharacter(std::string charName);
virtual ~PlayerCharacter();
protected:
std::string name;
Pos position;
};
That is PlayerChracter.cpp:
#include "PlayerCharacter.h"
PlayerCharacter::PlayerCharacter(std::string charName)
{
name = charName;
position.xPos = 0;
position.yPos = 0;
}
PlayerCharacter::~PlayerCharacter()
{
}
If I try to build project by the visual studio, I get this error:
1>------ Build started: Project: JanturiolGameServer, Configuration: Debug Win32 ------
1>JanturiolGameServer.cpp
1>JanturiolGameServer.obj : error LNK2019: unresolved external symbol "public: __thiscall PlayerCharacter::PlayerCharacter(class std::basic_string,class std::allocator >)" (??0PlayerCharacter##QAE#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function "private: void __thiscall JanturiolGameServer::ProcessDatagram(class QByteArray &)" (?ProcessDatagram#JanturiolGameServer##AAEXAAVQByteArray###Z)
1>C:\Users\GKR\source\repos\JanturiolGameServer\Win32\Debug\JanturiolGameServer.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "JanturiolGameServer.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If I try to build project by the Qt creator 4. 9. 0, I get this error:
https://monosnap.com/file/f9XQ1s0VQpfx8e6PXYtkaNl2X409ra
That is path to .lib file:
https://monosnap.com/file/oeaH3vuXMIYQ7aLY3vcWd6qk0QqOOy
In your project file you have set WIN64 but your compiler output states Debug Win32.
See "You attempt to link 64-bit libraries to 32-bit code, or 32-bit libraries to 64-bit code" as possible cause at https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2019?view=vs-2019

75:15: fatal error: stdlib.h: No such file or directory #include_next <stdlib.h>

I'm a beginner in working with CGAL libraries , I tried to run a combinatorial map example qt-creator on fedora after combiling CGAL:
#include <QCoreApplication>
#include <CGAL/Combinatorial_map.h>
#include <iostream>
#include <cstdlib>
typedef CGAL::Combinatorial_map<3> CMap_3;
typedef CMap_3::Dart_const_handle Dart_const_handle;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
CMap_3 cm;
// Create two tetrahedra.
Dart_const_handle dh1 = cm.make_combinatorial_tetrahedron();
Dart_const_handle dh2 = cm.make_combinatorial_tetrahedron();
// Display the combinatorial map characteristics.
cm.display_characteristics(std::cout);
std::cout<<", valid="<<cm.is_valid()<<std::endl;
unsigned int res = 0;
// Iterate over all the darts of the first tetrahedron.
// Note that CMap_3::Dart_of_orbit_range<1,2> in 3D is equivalent to
// CMap_3::Dart_of_cell_range<3>.
for (CMap_3::Dart_of_orbit_range<1,2>::const_iterator
it(cm.darts_of_orbit<1,2>(dh1).begin()),
itend(cm.darts_of_orbit<1,2>(dh1).end()); it!=itend; ++it)
++res;
std::cout<<"Number of darts of the first tetrahedron: "<<res<<std::endl;
res = 0;
// Iterate over all the darts of the facet containing dh2.
for (CMap_3::Dart_of_orbit_range<1>::const_iterator
it(cm.darts_of_orbit<1>(dh2).begin()),
itend(cm.darts_of_orbit<1>(dh2).end()); it!=itend; ++it)
++res;
std::cout<<"Number of darts of the facet containing dh2: "<<res<<std::endl;
return a.exec();
}
.pro file:
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp
INCLUDEPATH += /usr/include
LIBS += -lgmp -lmpfr -lCGAL
but it shows the following error:
In file included from /usr/include/c++/7/bits/stl_algo.h:59:0,
from /usr/include/c++/7/algorithm:62,
from /usr/include/QtCore/qglobal.h:68,
from /usr/include/qt5/QtCore/qcoreapplication.h:43,
from /usr/include/qt5/QtCore/QCoreApplication:1,
from ../untitled/main.cpp:1:
/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
I searched about the problem , but nothing is working with me
I appreciate any help
thanks
I solved it by removing INCLUDEPATH += /usr/include from .pro file
I got an solution: replace all #include_next with #include.

glew linking problems qt creator qmake

I am trying to get a project working with SDL2, assimp, opengl, and glew and cannot get glew to link properly (almost a duplicate but a more comprehensive question and answer, I think).
My qmake .pro file :
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
HEADERS += \
objloader.h \
display.h \
eventloop.h \
shader.h \
texture.h
SOURCES += main.cpp \
objloader.cpp \
display.cpp \
eventloop.cpp \
shader.cpp \
texture.cpp
INCLUDEPATH += "C:/code middleware/glew-1.12.0/include/" \
"C:\code middleware\glm\\" \
"C:\code middleware\SDL2-2.0.3\include\\" \
"C:\Users\smart_000\Desktop\assimp\include\\"
DEPENDPATH += "C:/code middleware/glew-1.10.0/bin/Release\Win32/" \
"C:\code middleware\SDL2-2.0.3\lib/x86/" \
"C:/Users/smart_000/Desktop/assimp/bin/" \
"C:/code middleware/glew-1.12.0/lib/Release/Win32/" \
"C:/code middleware/glew-1.12.0/bin/Release/Win32/"
LIBS += -L"C:\code middleware\SDL2-2.0.3\lib\x86" -lSDL2main -lSDL2
LIBS += -L"C:/Users/smart_000/Desktop/assimp/lib/" -lassimp.dll -lzlib
LIBS += -lopengl32
LIBS += -lglu32
LIBS += -L"C:/code middleware/glew-1.12.0/lib/Release/Win32/" -lglew32 -lglu32
The linker errors I am getting: linker errors
What I have tried already:
Checking file path problems ('/' and '\' kind of stuff and spaces in file names etc.)
Linking dynamically and statically (Yes, I defined GLEW_STATIC where I needed to, and I linked to -lglew32s and such)
SDL stuff: messing with and defining 'NO_SDL_GLEXT' above it
Making test programs and trying to link it with just g++ (I used the -static flag where I should have when I tried the static one and placed the linker flags after the files that needed them). These errors were the same as the qt ones minus the warnings.
Putting the glew source code directly in my project and building it (exact same errors) --- The issues were eerily similar and made no sense to me. I had commented out the qmake stuff and re ran qmake; I wasn't aware I could get linker errors like that if I put it in my project like I did.
Running qmake after my changes, lol
Moving 'LIBS' and 'DEPENDPATH' around and added 'CONFIG += opengl' in desperation
Messing with debug and release builds.
What I haven't tried:
Moving libraries and things to the system path
MAKING SURE THE LIBRARIES WERE BUILT FOR MINGW!
The relevant code(I know it's terrible; I was just hacking around when I encountered these issues) :
"main.cpp" :
#include <GL/glew.h>
#include <iostream>
#include <SDL.h>
#include <objloader.h>
#include "display.h"
#include "eventloop.h"
Display* display = NULL;
void callback()
{
std::cout << "yay" << std::endl;
display->Swap();
}
int main(int argc, char* argv[])
{
UShortVector indices;
Vec3Vector vertices;
Vec2Vector uvs;
Vec3Vector normals;
bool success = ObjLoader::loadObj("cube.obj", indices, vertices, uvs, normals);
display = new Display();
EventLoop eventLoop;
eventLoop.SetLoopCallback(&callback);
display->Create("yay");
eventLoop.Start();
return 0;
}
"display.h"
#ifndef DISPLAY_H
#define DISPLAY_H
#include <GL/glew.h>
#include <SDL.h>
#include <iostream>
class Display
{
public:
Display();
~Display();
void Create(const char* title);
void Swap();
SDL_Window* window_ = NULL;
SDL_GLContext glContext_;
};
#endif // DISPLAY_H
"shader.h"
#ifndef SHADER_H
#define SHADER_H
#include <GL/glew.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <memory.h>
class Shader
{
public:
GLuint LoadShaders(const char * vertex_file_path, const char * fragment_file_path);
private:
Shader();
~Shader();
};
#endif // SHADER_H
"shader.cpp"
#include "shader.h"
Shader::Shader()
{
}
Shader::~Shader()
{
}
GLuint Shader::LoadShaders(const char * vertexShaderPath, const char * fragmentShaderPath)
{
FILE* vertexFile = fopen(vertexShaderPath, "r");
FILE* fragmentFile = fopen(fragmentShaderPath, "r");
if(!vertexFile || !fragmentFile)
{
if(!vertexFile)
{
perror("could not open the vertex shader file");
}
if(!fragmentFile)
{
perror("could not open the fragment shader file");
}
}
GLuint programID = glCreateProgram();
GLuint vertShader = glCreateShader(GL_VERTEX_SHADER);
GLuint fragShader = glCreateShader(GL_FRAGMENT_SHADER);
const size_t MAX_LINE_LENGTH = 120;
char line[MAX_LINE_LENGTH];
std::vector<GLchar*> vertShaderSource;
std::vector<GLchar*> fragmentShaderSource;
while(fgets(line, MAX_LINE_LENGTH, vertexFile) != NULL)
{
vertShaderSource.push_back((GLchar*)line);
memset((void*)line, '\0', sizeof(line));
}
while(fgets(line, MAX_LINE_LENGTH, fragmentFile) != NULL)
{
fragmentShaderSource.push_back((GLchar*)line);
memset((void*)line, '\0', sizeof(line));
}
glShaderSource(vertShader, vertShaderSource.size(), (const GLchar**)&vertShaderSource, NULL);
glShaderSource(fragShader, fragmentShaderSource.size(), (const GLchar**)&fragmentShaderSource, NULL);
// doesn't do anything at the moment, I know. It should still compile though.
return programID;
}
Right after I posted the question, I found the issue. Embarrassingly, it was an issue I have run into before with assimp (although I just now realized why re-building it with cmake worked).
The hallmarks:
Weird linker errors with a library when you know the library is being found.
You primarily work on a windows system :)
The solution:
Check the build kit that you are using with Qt creator Vs. the libs you are using.
I was using the MINGW one only and my libs were compiled using the MSVC++ compiler
The libs you are looking for are .a files: specifically lib{name}.a . In this case, I was looking for libglew32.dll.a <- note the .dll in there for whether it is a dll import library or a static one like libglew32s.a <- note the s for static.
Where to go to get the rights libs :
- Go here for building it: Building glew on windows with mingw.
- Go here to download the pre-built one that I did (older version of glew): https://launchpad.net/glew-cmake/+milestone/1.10.0
The Download link that I used: glew-gcc-1.10.0-win32.zip (md5) Glew-Cmake 1.10.0 Binaries (MinGW) <- I tried to post a picture, but apparently, I am not cool enough to do that yet.
My updated and working qmake .pro file :
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
HEADERS += \
objloader.h \
display.h \
eventloop.h \
shader.h \
texture.h
SOURCES += main.cpp \
objloader.cpp \
display.cpp \
eventloop.cpp \
shader.cpp \
texture.cpp
INCLUDEPATH += "C:/code middleware/glew-gcc-1.10.0-win32/include/" \
"C:/code middleware/glm/" \
"C:/code middleware/SDL2-2.0.3/include/" \
"C:/Users/smart_000/Desktop/assimp/include/"
DEPENDPATH += "C:/code middleware/SDL2-2.0.3/lib/x86/" \
"C:/Users/smart_000/Desktop/assimp/bin/" \
"C:/code middleware/glew-gcc-1.10.0-win32/lib/" \
"C:/code middleware/glew-gcc-1.10.0-win32/bin/"
LIBS += -L"C:/code middleware/SDL2-2.0.3/lib/x86" -lSDL2main -lSDL2
LIBS += -L"C:/Users/smart_000/Desktop/assimp/lib/" -lassimp.dll -lzlib
LIBS += -L"C:/code middleware/glew-gcc-1.10.0-win32/lib/" -lglew32.dll
LIBS += -lopengl32
LIBS += -lglu32
Note: Don't forget the .dll on the end of the libs (-lglew32.dll).
- Happy Linking!

Error while opening a video with OpenCV and Qt

I have about 15 errors, when I want to get a video capture to view it frame by frame in an image.
First I call my video from my link.
Then get from it my frame.
Then convert it into image.
Finally view it in pixmap.
MY CODE
#include "form1.h"
#include "ui_form1.h"
#include <QtCore>
#include <QtGui>
#include <QGraphicsAnchorLayout>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsWidget>
#include "qimage.h"
#include <QFileDialog>
#include <QPixmap>
#include "qpixmap.h"
Form1::Form1(QWidget *parent) :
QDialog(parent),
ui(new Ui::Form1)
{
ui->setupUi(this);
video->open("D:/Downloads/DirectX/Zlatan Ibrahimovic ● Taekwondo Goals.mp4");
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updatePicture()));
timer->start(20);
}
QString fileName;
QImage Form1::getQImageFromFrame(cv::Mat frame) {
//converts the color model of the image from RGB to BGR because OpenCV uses BGR
cv::cvtColor(frame, frame, CV_RGB2BGR);
return QImage((uchar*) (frame.data), frame.cols, frame.rows, frame.step, QImage::Format_RGB888);
}
Form1::~Form1()
{
delete ui;
}
void Form1::updatePicture()
{
cv::Mat frame1;
video->operator >>( frame1);
img = getQImageFromFrame(frame1);
ui->label->setPixmap(QPixmap::fromImage(img));
}
void Form1::on_pushButton_clicked()
{
//fileName = QFileDialog::getOpenFileName(this,
//tr("Open Image"), "/elhandasya/Desktop", tr("Image Files (*.png *.jpg *.bmp)"));
//QPixmap pix(fileName);
}
'
The errors like this:
undefined reference to `cv::Mat::Mat()
D:\ubunto\QT5\Tools\QtCreator\bin\Video_Player-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug\debug\form1.o:-1: In function `ZN5Form1D2Ev'
My LIBS
#-------------------------------------------------
#
# Project created by QtCreator 2013-12-16T09:23:28
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Video_Player
TEMPLATE = app
SOURCES += main.cpp\
form1.cpp
HEADERS += form1.h
FORMS += form1.ui
INCLUDEPATH += -I"D:/ubunto/OpenCV/opencv/build/include/opencv2/imgproc"
INCLUDEPATH += -I"D:/ubunto/OpenCV/opencv/build/include/"
#INCLUDEPATH += "D:/ubunto/OpenCV/opencv/build/include/"
LIBS += -LD:/ubunto/OpenCV/opencv/build/x86/mingw/bin
-lopencv_core
-lopencv_imgproc
-lopencv_highgui
-lopencv_legacy
-lopencv_gpu
-lopencv_video
-lopencv_ml
-lopencv_contrib
#LIBS += D:\ubunto\emgu\emgucv-windows-x86 2.4.0.1717\lib
#-opencv_calib3d240
#-opencv_videostab240
#-opencv_calib3d240
#-opencv_contrib240
#-opencv_core240
#-opencv_features2d240
#-opencv_flann240
#-opencv_gpu240
#-opencv_highgui240
#-opencv_imgproc240
#-opencv_legacy240
#-opencv_ml240
#-opencv_nonfree240
#-opencv_objdetect240
#-opencv_photo240
#-opencv_stitching240
#-opencv_video240
If you take a look at the source code of cvVideo (an application that shows how to create a Qt window to display videos loaded with OpenCV) you can see how to achieve what you are looking for.
cvVideo.pro:
TEMPLATE = app
QT += core gui
contains(QT_VERSION, ^5\\.[0-8]\\..*) {
message("* Using Qt $${QT_VERSION}.")
QT += widgets
# On my system I have to specify g++ as compiler else it will use clang++ by default
#QMAKE_CXX=g++
#QMAKE_CC=gcc
}
HEADERS += \
cvWindow.h
SOURCES += \
main.cpp \
cvWindow.cpp
## OpenCV settings for Unix/Linux
unix:!mac {
message("* Using settings for Unix/Linux.")
INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib/ \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgproc
}
## OpenCV settings for Mac OS X
macx {
message("* Using settings for Mac OS X.")
INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib/ \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgproc
}
## OpenCV settings for Windows and OpenCV 2.4.2
win32 {
message("* Using settings for Windows.")
INCLUDEPATH += "C:\\opencv\\build\\include" \
"C:\\opencv\\build\\include\\opencv" \
"C:\\opencv\\build\\include\\opencv2"
LIBS += -L"C:\\opencv\\build\\x86\\vc10\\lib" \
-lopencv_core242 \
-lopencv_highgui242 \
-lopencv_imgproc242
}
# Runs this app automatically after the building has succeeded
#QMAKE_POST_LINK=./$$TARGET
Error tells you that you have to link, in you makefile, the specific library that include Mat:
-lopencv_core
Take a look at the documentaion.
When there are errors like:
In function `ZN5Form1D2Ev'
It could be that you have two different opencv version installed, isn't it?