QT 5.6 with OPenCV Run time 0xc0000139 - qt

Anyone got QT 5.6 working with OpenCV ?
Tried OpenCV latest 2.4.13 (at time of writing) and went back to OpenCV 2.4.9.
None worked - program will compile, link but crash on "During Startup program exited with code 0xc0000139". I never had any problems with QT 5.5.1 and OpenCV.
Here is stripped down code:
**mainwindow.cpp:**
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv/cv.h>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
cv::Mat image = cv::imread("C:/Users/foo/pics/cheetah.jpg");
cv::namedWindow("My Image");
cv::imshow("My Image", image);
cvWaitKey(0);
}
MainWindow::~MainWindow()
{
delete ui;
}
**main.cpp (used default):**
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
**mainwindow.h: (used default)**
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
**test_opencv.pro:**
INCLUDEPATH += "C:\Users\foo\Downloads\opencv\build\include"
LIBS += -LC:\Users\foo\Downloads\opencv\build\lib \
-lopencv_core249.dll \
-lopencv_highgui249.dll \
-lopencv_imgproc249.dll \
-lopencv_features2d249.dll \
-lopencv_video249.dll \
-lopencv_calib3d249.dll
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test_opencv
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
Path set:
C:\Qt\Tools\mingw492_32\bin
C:\Qt\5.6\mingw49_32\bin
C:\Users\foo\Downloads\opencv\build\bin
QT works fine with no OpenCV calls. With above code, running with QT Debug will see this:
"During Startup program exited with code 0xc0000139".
QT Error message
I have double checked my path. The OpenCV DLLs are defined in the Path. problem is not about not finding the runtime dynamically link dlls. I also checked my System32 and other directories for any old OpenCV dlls that might interfere as the path is traversed. No issues.
OpenCV was built with CMake and successfully build and installed. No issues there.
Thanks
Sean

Related

(epics)QT compilation error: "undefined reference to"

I am brand new to programming with Qt. I'm trying to do a simple subtraction of some values fed from an epicsQt widget called QELabel, which simply reads the value of an EPICS channel. I want to subtract values from two QELabels and print it to another QELabel. But, I'm getting 'undefined reference to' errors for these ->
MainWindow::on_qeLabel_dbValueChanged(QString const&) MainWindow::on_ShutterOpen_dbValueChanged(QString const&)
Here is the bit of mainwindow.cpp (I followed the example from this youtube video, especially after about the 15 minute mark)
void MainWindow::on_TopShutter_dbValueChanged(const QString &out)
{
double top,bottom,open;
top=ui->TopShutter->text().toDouble();
bottom=ui->BottomShutter->text().toDouble();
open=top-bottom
ui->ShutterOpen->setText(Qstring::number(open));
}
I'm using QTCreator, so I don't have the usual errors that I've been seeing in other forums. I have the slot declared in the header file, and MainWindow set as a Q_Object (this is the whole mainwindow.h file):
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_qelabel_dbValueChanged(const QString &out);
void on_ShutterOpen_dbValueChanged(const QString &out);
void on_TopShutter_dbValueChanged(const QString &out);
private:
Ui::MainWindow *ui;
};
#endif //MAINWINDOW_H
Because they are short, and for completeness, here is the main.cpp, and then the .pro
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
And the FirstWeatherAlarm.pro:
#-------------------------------------------------
QT += core gui xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = FirstWeatherAlarm
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
LIBS += -L/usr/lib64/qt5/plugins/designer -lQEPlugin
INCLUDEPATH += /home/jchavez/epicsqt/3.1.0/framework/include
HEADERS += mainwindow.h
FORMS += mainwindow.ui
Have I got everything declared right at the start of all the files? What is missing so that my slots are not right? I created the slot in the gui, using the "right-click" on my QELabel, and selecting "Go to Slot", so I should think all the formatting would be correct. As I've been editing, I've also run qmake and make clean which are other answers I've seen on forums. But nothing is working.
The problem is with two slots:
MainWindow::on_qeLabel_dbValueChanged(QString const&)
MainWindow::on_ShutterOpen_dbValueChanged(QString const&)
They are declared in MainWindow.h file and used somewhere in your project (otherwise you won't get an error).
But they are not implemented in mainwindow.cpp. You should add implementation to this file and the error will go away.
You have implementation for
void MainWindow::on_TopShutter_dbValueChanged(const QString &out)
in mainwindow.cpp, you can add implementation for two more slots. Think about slot as a function. And read more about signals/slots.

Image not shown using Qpixmap with QT5.4 and mvs2013 x64

I am using QT (version 5.4 msvc2013_64) with of-course vs2013. The compilation is successful but when running not every thing functions. Before with vs2010 and QT (i think version 5.1 msvc_2010_opengl do not remember exactly) every thing was working but now things are wried which maybe typical with the start of newer versions but need to be resolved. I also got other issues with this but lets get this resolved first as maybe others will be resolved too else I will post another question for the other problems. Of-course If i do not see a solution to this problem with the current QT and vs I will switch to vs2012 (requires downloading and installing); Maybe then everything will work as before. Thanks in advance.
ui_ta7feezquran.h
/********************************************************************************
** Form generated from reading UI file 'ta7feezquran.ui'
**
** Created by: Qt User Interface Compiler version 5.4.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_TA7FEEZQURAN_H
#define UI_TA7FEEZQURAN_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_Ta7feezQuranClass
{
public:
QWidget *centralWidget;
QLabel *a;
QMenuBar *menuBar;
QToolBar *mainToolBar;
void setupUi(QMainWindow *Ta7feezQuranClass)
{
if (Ta7feezQuranClass->objectName().isEmpty())
Ta7feezQuranClass->setObjectName(QStringLiteral("Ta7feezQuranClass"));
Ta7feezQuranClass->resize(572, 485);
centralWidget = new QWidget(Ta7feezQuranClass);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
a = new QLabel(centralWidget);
a->setObjectName(QStringLiteral("a"));
a->setGeometry(QRect(-30, -20, 601, 471));
a->setPixmap(QPixmap(QString::fromUtf8(":/Ta7feezQuran/Resources/Amasjed Alharam.jpg")));
a->setScaledContents(true);
Ta7feezQuranClass->setCentralWidget(centralWidget);
menuBar = new QMenuBar(Ta7feezQuranClass);
menuBar->setObjectName(QStringLiteral("menuBar"));
menuBar->setGeometry(QRect(0, 0, 572, 21));
menuBar->setLayoutDirection(Qt::RightToLeft);
Ta7feezQuranClass->setMenuBar(menuBar);
mainToolBar = new QToolBar(Ta7feezQuranClass);
mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
Ta7feezQuranClass->addToolBar(Qt::TopToolBarArea, mainToolBar);
retranslateUi(Ta7feezQuranClass);
QMetaObject::connectSlotsByName(Ta7feezQuranClass);
} // setupUi
void retranslateUi(QMainWindow *Ta7feezQuranClass)
{
Ta7feezQuranClass->setWindowTitle(QApplication::translate("Ta7feezQuranClass", "Ta7feezQuran", 0));
a->setText(QString());
} // retranslateUi
};
namespace Ui {
class Ta7feezQuranClass: public Ui_Ta7feezQuranClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_TA7FEEZQURAN_H
ta7feezquran.h
#ifndef TA7FEEZQURAN_H
#define TA7FEEZQURAN_H
#include <QtWidgets/QMainWindow>
#include "ui_ta7feezquran.h"
class Ta7feezQuran : public QMainWindow
{
Q_OBJECT
public:
Ta7feezQuran(QWidget *parent = 0);
~Ta7feezQuran();
private:
Ui::Ta7feezQuranClass ui;
};
#endif // TA7FEEZQURAN_H
ta7feezquran.cpp
#include "ta7feezquran.h"
Ta7feezQuran::Ta7feezQuran(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}
Ta7feezQuran::~Ta7feezQuran()
{
}
main.cpp
#include "ta7feezquran.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Ta7feezQuran w;
w.show();
return a.exec();
}
ta7feezquran.qrc
<RCC>
<qresource prefix="/Ta7feezQuran">
<file>Resources/Amasjed Alharam.jpg</file>
</qresource>
</RCC>
Some Application features used, for example images, multimedia, print support, etc., require the use of qt plugins.
The required plugins should be copied to the executable folder (folder where .exe file is included) by copying the plugin folders (with the dlls included) and pasting them inside the executable folder. Every thing else should work as expected.
In this case imageformats folder (with qjpeg.dll included as the file used is jpg) is needed to copied.

In Qt 5, where is the header file for my form?

I'm new to Qt and the book is for Qt 4.
When I create a dialog.ui or mainwindow.ui file, it places it under the Folder forms. I do not see any header files or anything like that. How can I reference my dialog.ui it in my main.cpp file?
Getting error ui uses undefined class Ui::MainWindow.
Thank you!
#include <QApplication>
#include <QDialog>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Ui::MainWindow ui;
QDialog *dialog = new QDialog;
ui.setupUi(dialog);
dialog->show();
return a.exec();
}
.pro file:
#-------------------------------------------------
#
# Project created by QtCreator 2014-05-22T17:21:36
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled7
TEMPLATE = app
SOURCES += main.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
qt 5 implementation which is autogenerated:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
Ui::MainWindow is a private class which is accessible by the MainWindow class only. You cannot use it anywhere else (e.g. main()).
Ui::MainWindow is defined in ui_mainwindow.h, which is auto-generated when you compile your app.
To create an GUI based on mainwindow.ui, simply instantiate a MainWindow object:
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow mw;
mw.show();
return a.exec();
}
Notes:
When you create a new Qt Widgets Application in Qt Creator, main.cpp is auto-
generated for you. You don't need to write it yourself.
Qt's User Interface Compiler parses mainwindow.ui and generates
ui_mainwindow.h in your build directory. It is automatically run when you build
your app in Qt Creator. You don't need to run it manually.

Cross-platform Qt5 project using cmake

I am familiar with Qt4 but we are trying to transition to Qt5 and it's being very difficult. I'm trying to create a very simple application, and I had it working using the Qt PRO file, but we need to base it on cmake to keep the build server happy.
The error I get is "invalid use of incomplete type ‘struct Ui::MainWindow’" in the line in mainwindow.cpp where it constructs "ui(new Ui::MainWindow)".
Here are my files (simplified to shorten this post):
mainwindow.h
#include <QtWidgets/QMainWindow>
namespace Ui { class MainWindow; }
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
mainwindow.cpp
#include "mainwindow.h"
#include "moc_mainwindow.cpp"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{ }
MainWindow::~MainWindow()
{ delete ui; }
cmakelists.txt
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.9 FATAL_ERROR )
PROJECT(Test)
set(CMAKE_AUTOMOC TRUE)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
file (GLOB Sources src/*.cpp )
add_executable(Test ${Sources} src/mainwindow.ui )
qt5_use_modules(Test Widgets)
I'm sure I'm missing something obvious, but I've been looking all day and can't figure this one out ...
Looking at the generated moc_mainwindow.cpp (again, some lines truncated to keep this post short):
#include "../src/mainwindow.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
QT_BEGIN_MOC_NAMESPACE
void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
QT_END_MOC_NAMESPACE
I am guessing that MainWindow::qt_static_metacall() is declared in my mainwindow.h in the Q_OBJECT macro. which means I have no idea where this mystical Ui::MainWindow is coming from. Or not.
UPDATE
The problem seems to be that in my mainwindow.cpp, I should be #including "ui_mainwindow.h" instead of "moc_mainwindow.cpp", but there is no "ui_mainwindow.h" being generated, only moc_mainwindow.cpp.
Turns out my understanding of Qt was completely WRONG. moc doesn't generate those ui files, it's doing other magic to make signals & slots work. The solution is to add this link to CMakeLists.txt:
qt5_wrap_ui(uifiles src/mainwindow.ui)

Qt application that uses CUDA runtime libraries does not run when double-clicking

I'm learning to build Qt + CUDA applications on linux (Ubuntu 12.04 64 bit). For starters, I am trying to build an application that checks the number of CUDA enabled devices on my computer.
I am able to launch the application from within Qt Creator but not by double clicking on the app. I can run it by issuing ./device_query in the terminal (the name of the app is device_query).
I have a simple UI (the default created by Qt Creator when a Qt gui app is created)
Here are the other files
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <cuda_runtime.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
int count;
cudaGetDeviceCount(&count); //when this line is added, unable to double click and launch
}
MainWindow::~MainWindow()
{
delete ui;
}
main.cpp
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QtDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
.pro file
QT += core gui
TARGET = device_query
TEMPLATE = app
HEADERS = mainwindow.h
SOURCES += main.cpp\
mainwindow.cpp
FORMS += mainwindow.ui
INCLUDEPATH += /usr/local/cuda/include
LIBS += -L/usr/local/cuda/lib64/ -lcudart
Why is it that I am not able to run the application by double clicking it?
The issue is probably with $LD_LIBRARY_PATH not being set for the application when it is launched by double-click. In Nsight Eclipse Edition we have a shell script that initializes the environment and then starts the IDE - this way you can start Nsight from the desktop menus.

Resources