I'm having problems including winscard.lib in my QT project.
I have windows 10 x64 and I downloaded the microsoft sdk V7.1 because I didn't have the winscard library in the microsoft sdk v10.
Now, my .pro file looks like this:
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = NFC
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
mainwindow.cpp \
globs.cpp \
newcard.cpp \
newcircuitnumber.cpp
HEADERS += \
mainwindow.h \
globs.h \
newcard.h \
newcircuitnumber.h
FORMS += \
mainwindow.ui \
newcard.ui \
newcircuitnumber.ui
INCLUDEPATH += "C:\Program Files\Microsoft SDKs\Windows\v7.1\Include"
LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\IA64"
LIBS += -winscard -lz
mainwindow.h
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDir>
#include <QDebug>
#include <QMessageBox>
#include <QSqlQuery>
#include "globs.h"
#include "qt_windows.h"
#include "winnt.h"
#include "winscard.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
SCARDCONTEXT cardContext;
LPWSTR mszReaders;
DWORD dwReaders;
SCardEstablishContext(SCARD_SCOPE_USER,NULL,NULL,&cardContext);
dwReaders = SCARD_AUTOALLOCATE;
SCardListReadersW(cardContext,NULL,(LPWSTR)&mszReaders,&dwReaders);
QByteArray buffer;
wchar_t *it = mszReaders;
while(*it !='\0')
{
buffer.append(QChar(*it));
*it++;
}
qDebug()<<buffer;
}
The error I get when I try to compile are the following:
Errors
Can somebody point me to a solution? What am I doing wrong?
Thanks a lot in advance.
Related
I'm pretty new to qt and i'm trying to create a widget that showing my webcam using qt and opencv. As the title has stated that i'm stuck at the LNK1107: invalid or corrupt file cannot read 0x458. After having done some research, i discovered that this issues have been addressed in multiple topic, but not with 0x458 in particular
Any aid would be greatly appriciated, from the bottom of my heart
here's my code:
.pro:
#-------------------------------------------------
#
# Project created by QtCreator 2019-08-10T12:27:53
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TutorialOpenCV
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
main.cpp \
mainwindow.cpp \
myvideocapture.cpp
HEADERS += \
mainwindow.h \
myvideocapture.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../opencv/build/x64/vc15/lib/ -lopencv_world451
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../opencv/build/x64/vc15/lib/ -lopencv_world451d
else:unix: LIBS += -L$$PWD/../../../../../opencv/build/x64/vc15/lib/ -lopencv_world451
INCLUDEPATH += C:\opencv\build\x64\vc15
LIBS += C:\opencv\build\x64\vc15\lib\opencv_world451.lib
LIBS += C:\opencv\build\x64\vc15\lib\opencv_world451d.lib
INCLUDEPATH += $$PWD/../../../../../opencv/build/include
DEPENDPATH += $$PWD/../../../../../opencv/build/include
INCLUDEPATH += C:\opencv\release\install\include
LIBS += C:\opencv\release\bin\libopencv_core451.dll
LIBS += C:\opencv\release\bin\libopencv_highgui451.dll
LIBS += C:\opencv\release\bin\libopencv_imgcodecs451.dll
LIBS += C:\opencv\release\bin\libopencv_imgproc451.dll
LIBS += C:\opencv\release\bin\libopencv_features2d451.dll
LIBS += C:\opencv\release\bin\libopencv_calib3d451.dll
INCLUDEPATH += C:\opencv\release\install\include\opencv2
INCLUDEPATH += C:\opencv\release\install\include\opencv
INCLUDEPATH += C:\opencv\build\include
INCLUDEPATH += C:\opencv\release\include
LIBS += C:\opencv\release\install\x64\mingw\bin\libopencv_core451.dll
LIBS += C:\opencv\release\install\x64\mingw\bin\libopencv_highgui451.dll
LIBS += C:\opencv\release\install\x64\mingw\bin\libopencv_imgcodecs451.dll
LIBS += C:\opencv\release\install\x64\mingw\bin\libopencv_imgproc451.dll
LIBS += C:\opencv\release\install\x64\mingw\bin\libopencv_features2d451.dll
LIBS += C:\opencv\release\install\x64\mingw\bin\libopencv_calib3d451.dll
myvideocapture.cpp:
#include "myvideocapture.h"
#include <QDebug>
MyVideoCapture::MyVideoCapture(QObject *parent)
: QThread { parent }
, mVideoCap { ID_CAMERA }
{
}
void MyVideoCapture::run()
{
if (mVideoCap.isOpened())
{
while (true)
{
mVideoCap >> mFrame;
if (!mFrame.empty())
{
cv::rectangle(mFrame, cv::Point(10, 10), cv::Point(401, 401), cv::Scalar(0, 0, 255), 1);
mPixmap = cvMatToQPixmap(mFrame);
emit newPixmapCaptured();
}
}
}
}
QImage MyVideoCapture::cvMatToQImage(const cv::Mat &inMat)
{
switch (inMat.type())
{
// 8-bit, 4 channel
case CV_8UC4:
{
QImage image(inMat.data, inMat.cols, inMat.rows, static_cast<int>(inMat.step), QImage::Format_ARGB32);
return image;
}
// 8-bit, 3 channel
case CV_8UC3:
{
QImage image(inMat.data, inMat.cols, inMat.rows, static_cast<int>(inMat.step), QImage::Format_RGB888);
return image.rgbSwapped();
}
// 8-bit, 1 channel
case CV_8UC1:
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
QImage image(inMat.data, inMat.cols, inMat.rows, static_cast<int>(inMat.step), QImage::Format_Grayscale8);
#else
static QVector<QRgb> sColorTable;
// only create our color table the first time
if (sColorTable.isEmpty())
{
sColorTable.resize(256 );
for (int i = 0; i < 256; ++i )
{
sColorTable[i] = qRgb(i, i, i );
}
}
QImage image(inMat.data,
inMat.cols, inMat.rows,
static_cast<int>(inMat.step),
QImage::Format_Indexed8 );
image.setColorTable(sColorTable );
#endif
return image;
}
default:
{
qWarning()<< "ASM::cvMatToQImage()- cv::Mat image type not handled in switch:" << inMat.type();
break;
}
}
return QImage();
}
QPixmap MyVideoCapture::cvMatToQPixmap(const cv::Mat &inMat)
{
return QPixmap::fromImage(cvMatToQImage(inMat));
}
mainwindow.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "myvideocapture.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
mOpenCV_videoCapture = new MyVideoCapture(this);
connect(mOpenCV_videoCapture, &MyVideoCapture::newPixmapCaptured, this, [&]()
{
ui->opencvFrame->setPixmap(mOpenCV_videoCapture->pixmap().scaled(500, 500));
});
}
MainWindow::~MainWindow()
{
delete ui;
mOpenCV_videoCapture->terminate();
}
void MainWindow::on_iniciarOpenCV_button_clicked()
{
mOpenCV_videoCapture->start(QThread::HighestPriority);
}
main.cpp:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setStyle("fusion");
MainWindow w;
w.show();
return a.exec();
}
I have been following this tutorial and I did all of them carefully.
But afterwards I ran the simple code:
I saw this error and how can I fix it?
Tutorial:
https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows
I removed qt and opencv and I used the version that used in the tutorial that I mentioned but I got the same error.
And also I added "img.jpg" to my project directory.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
Mat image = imread("img.jpg", 1);
namedWindow("My Image");
imshow("My Image", image);
waitKey(0);
}
MainWindow::~MainWindow()
{
delete ui;
}
and I added them to my .pro file:
INCLUDEPATH += C:\OpenCV-Qt\build\install\include
LIBS += C:\OpenCV-Qt\build\bin\libopencv_core320.dll.a
LIBS += C:\OpenCV-Qt\build\bin\libopencv_highgui320.dll
LIBS += C:\OpenCV-Qt\build\bin\libopencv_imgcodecs320.dll
LIBS += C:\OpenCV-Qt\build\bin\libopencv_imgproc320.dll
LIBS += C:\OpenCV-Qt\build\bin\libopencv_features2d320.dll
LIBS += C:\OpenCV-Qt\build\bin\libopencv_calib3d320.dll
I expect to create a window and show the image in it but I get the error:
C:\OpenCV-Qt\build\bin\libopencv_core320.dll:-1: error: LNK1107: invalid or corrupt file: cannot read at 0x3D0
I can't figure out how to link FTDI library in my Qt project. I copied ftd2xx.h file to my project directory. The file I want to link is dll: ftd2xx.lib which is stored in F:\Workspace\qt\libs\ftdi\amd64
I get error:
release/testftdi.o:testftdi.cpp:(.text+0x6f8): undefined reference to `_imp__FT_Open#8'
collect2.exe: error: ld returned 1 exit status
I have QtWidget application with one PushButton:
TestFtdi.pro file:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TestFtdi
TEMPLATE = app
LIBS += -L"F:\Workspace\qt\libs\ftdi\amd64" -lftd2xx
INCLUDEPATH += f:/Workspace/qt/libs/ftdi/amd64
SOURCES += main.cpp\
testftdi.cpp
HEADERS += testftdi.h
FORMS += testftdi.ui
main.cpp file:
#include "testftdi.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
TestFtdi w;
w.show();
return a.exec();
}
testftdi.h file:
#ifndef TESTFTDI_H
#define TESTFTDI_H
#include <QMainWindow>
namespace Ui {
class TestFtdi;
}
class TestFtdi : public QMainWindow
{
Q_OBJECT
public:
explicit TestFtdi(QWidget *parent = 0);
~TestFtdi();
private slots:
void on_pushButton_clicked();
private:
Ui::TestFtdi *ui;
};
#endif // TESTFTDI_H
testftdi.cpp file:
#include "testftdi.h"
#include "ui_testftdi.h"
#include <QDebug>
#include "windows.h"
#include "ftd2xx.h"
TestFtdi::TestFtdi(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::TestFtdi)
{
ui->setupUi(this);
}
TestFtdi::~TestFtdi()
{
delete ui;
}
void TestFtdi::on_pushButton_clicked()
{
FT_HANDLE ftHandle;
FT_STATUS ftStatus;
ftStatus = FT_Open(0, &ftHandle);
if(ftStatus != FT_OK) { // FT_Open failed
qDebug() << "FT_Open failed";
}
}
The compiler command looks in this situation like this:
g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\TestFtdi.exe release/main.o release/testftdi.o release/moc_testftdi.o -lmingw32 -LC:/Qt/5.5/mingw492_32/lib -lqtmain -lshell32 -LF:\Workspace\qt\libs\ftdi\Static\amd64 -lftd2xx -lQt5Widgets -lQt5Gui -lQt5Core
Could you help me with this?
My guess is, compiler might be looking for ftd2xx rather than ftd2xx.lib (file name is ftd2xx.lib.dll, right?). Have you tried changing the LIBS line to
LIBS += -L"F:\Workspace\qt\libs\ftdi\amd64" -lftd2xx.lib
I am trying to write a simple camara app. I created a new Project and add the EDSDK headers and the lib. Also i have added the init command EdsInitializeSDK().
test.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Test
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
LIBS += -L".\EDSDK.lib"
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <EDSDK.h>
#include <EDSDKErrors.h>
#include <EDSDKTypes.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
EdsError err=EDS_ERR_OK;
err = EdsInitializeSDK();
}
MainWindow::~MainWindow()
{
delete ui;
}
the main.cpp and mainwindow.h are not modified.
it compiled, but when i want to start the programm it crash without any error.
In debug i become the error 0xc0000135
I use the Canon_Camara_SDK_Kit_v2_14 with Qt on Win 7.
The EDSDK.lib are in the src and in the build Folder.
I have no Idea whats wrong
Thanks!
I try to use QwtPlot, but when i add this line to my MainWindow.cpp
QwtPlot *plot = new QwtPlot(QwtText("Demo"), this);
the application compile and link without errors, but when I try to run it I get
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff514227c in ?? () from /usr/lib/libQtGui.so.4
without any backtrace. My .pro file:
INCLUDEPATH += /usr/include/qwt
CONFIG += qwt
LIBS += -lqwt
I'm using Qwt 6.0.2, Qt Creator 2.7.0 and have Qt 4.8.4 and 5.0.2 installed.
The error also occours when I create a "Qt Gui Application" (without .ui file) and just this code:
qwt-test.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qwt-test
TEMPLATE = app
INCLUDEPATH += /usr/include/qwt
CONFIG += qwt
LIBS += -lqwt
SOURCES += main.cpp\
MainWindow.cpp
HEADERS += MainWindow.hpp
main.cpp
#include "MainWindow.hpp"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
qDebug() << "main";
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
MainWindow.hpp
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include <QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
};
#endif // MAINWINDOW_HPP
MainWindow.cpp
// MainWindow.cpp
#include "MainWindow.hpp"
#include <qwt_plot.h>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QwtPlot *plot = new QwtPlot(QwtText("Demo"), this);
}
MainWindow::~MainWindow()
{
}
Thanks!
It was a problem with Qt Creator (or Qwt being incompatible with Qt 5), it recognized qmake as qmake for Qt 4 but it was for Qt 5. Fixing the versions in Options -> Build&Run -> Qt Versions and using Qt 4 for the project fixed the segfault.