I am trying to use Octave with Qt creator on Windows but I don't no why i can't succeed to link this library on this OS. I already tried on Ubuntu and everything works so i am a little bit lost...
I have octave3.6.4 (gcc 4.6.2) and i use the compiler gcc4.6.2 with Qt Creator.
my .pro file:
#-------------------------------------------------
#
# Project created by QtCreator 2015-01-26T11:35:00
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
LIBS += -L$$PWD/../../../../Octave/Octave3.6.4_gcc4.6.2/lib/octave/3.6.4/ -loctave -loctinterp -lcruft
INCLUDEPATH += $$PWD/../../../../Octave/Octave3.6.4_gcc4.6.2/include
DEPENDPATH += $$PWD/../../../../Octave/Octave3.6.4_gcc4.6.2/include
PRE_TARGETDEPS += $$PWD/../../../../Octave/Octave3.6.4_gcc4.6.2/lib/octave/3.6.4/libcruft.dll.a
PRE_TARGETDEPS += $$PWD/../../../../Octave/Octave3.6.4_gcc4.6.2/lib/octave/3.6.4/liboctave.dll.a
PRE_TARGETDEPS += $$PWD/../../../../Octave/Octave3.6.4_gcc4.6.2/lib/octave/3.6.4/liboctinterp.dll.a
my .h file:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <octave-3.6.4/octave/oct.h>
#include <octave-3.6.4/octave/octave.h>
#include <octave-3.6.4/octave/parse.h>
#include <octave-3.6.4/octave/toplev.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
And i have many link errors such as C2144 syntax error ...
Related
This question already has an answer here:
no such file or directory
(1 answer)
Closed 2 years ago.
i'm trying to get the image from my webcam using qt, opencv
here's my codes:
.pro file:
#-------------------------------------------------
#
# Project created by QtCreator 2013-12-20T07:42:20
#
#-------------------------------------------------
QT += core gui
TARGET = QtCvCapture
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
imagecapture.cpp \
moc_imagecapture.cpp \
moc_mainwindow.cpp
HEADERS += mainwindow.h \
imagecapture.h \
ui_mainwindow.h
FORMS += mainwindow.ui
#include opencv for PC x86
#INCLUDEPATH += /usr/local/include/opencv
#LIBS +=/usr/local/lib/*.so
INCLUDEPATH += C:\opencv\build\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
#include opencv for ARM
#INCLUDEPATH += /opt/opencv.arm/include/opencv
#LIBS += /opt/opencv.arm/lib/*.so
imagecapture.h:
#ifndef IMAGECAPTURE_H
#define IMAGECAPTURE_H
#include <QObject>
#include <QImage>
#include <QTimer>
#include <cv.h>
#include <highgui.h>
class ImageCapture : public QObject
{
Q_OBJECT
public:
explicit ImageCapture(QObject *parent = 0);
~ImageCapture();
signals:
public slots:
//!< attempts to start camera, camera number is given in cameraIndex (see cvCaptureFromCAM docs)
void captureFromCamera( int cameraIndex = -1 ); //index = -1 to capture form any camera
void stopCapture(); //!< stops timer and release OpenCV capture structure
protected:
QImage convert(IplImage * image); //!< create QImage from OpenCV image data
QImage IplImage2QImage(const IplImage *iplImage);
protected slots:
void timer_stick(); //!< grab and send frame on each timer tick
signals:
void imageCaptured( const QImage& image );
void error( const QString& text );
protected:
QTimer * _timer; //!< timeout signal is used to capture frames at regular intervals (or whenever possible in case of camera)
CvCapture * _cvCap; //!< used to grab image data from video or camera
IplImage* imagerd;
};
#endif // IMAGECAPTURE_H
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <imagecapture.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
public slots:
void on_actionOpen_Camera_triggered();
void displayImage(const QImage &image);
protected slots:
void captureError(const QString &text);
public:
ImageCapture *_capture;
};
#endif // MAINWINDOW_H
(i don't know if this kind of presentation is acceptable, i haven't seen anyone doing it yet)
the problems are:
C:\Users\FPT Shop\Downloads\QtCvCapture\QtCvCapture\mainwindow.h:4: error: QMainWindow: No such file
or directory
In file included from ..\QtCvCapture\mainwindow.cpp:1:
..\QtCvCapture\mainwindow.h:4:10: fatal error: QMainWindow: No such file or directory
same issues for cv.h and QtGUI/QApplicaiton, this happended when i try to #include them
what I have done: I have installed OpenCV and CMake following the instruction in https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows#OpenCV
the installation was successful, after which I compiled the program, then I'm met with the errors above. I have recheck and the files that the compiler claimed to be missing are there, in the folder (which I have linked in the .pro file). I found some answer said that it could be because my code is outdated? which I found reasonable because the code that's I'm using was published wayy back in 2013... sooo
what do you guys think?
I'm including GLM header files in a QT project in QTCreator, but I keep getting encoding errors. All files seem to be set to UTF-8 and they are displayed normally on screen. I get several messages as the following:
C:\Users\Luís Longo\OneDrive\Dyno3D\linking\glm\detail\type_mat2x3.inl:-1: In member function 'glm::mat<2, 3, T, Q>::col_type& glm::mat<2, 3, T, Q>::operator[](glm::mat<2, 3, T, Q>::length_type)':
C:\Users\Luís Longo\OneDrive\Dyno3D\linking\glm\detail\type_mat2x3.inl:222: error: converting to execution character set: Illegal byte sequence
assert(i < this->length());
^
.pro file
QT += core gui opengl
LIBS += -lopengl32
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
INCLUDEPATH += $$PWD/linking/glm
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
GLPanel.cpp \
main.cpp \
mainwindow.cpp
HEADERS += \
GLPanel.h \
mainwindow.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
DISTFILES += \
fragment.glsl \
vertex.glsl
OpenGL Widget class
#ifndef GLPANEL_H
#define GLPANEL_H
#include <QWidget>
#include <QOpenGLWidget>
#include "glm.hpp"
class GLPanel : public QOpenGLWidget
{
public:
GLPanel(QWidget* parent);
protected:
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
private:
void InitializeOpenGLOptions();
};
#endif // GLPANEL_H```
It seems the problem was due to the filepath, which has a "í" character. Changing the project folder has solved the problem.
This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 7 months ago.
I've been banging my head against the wall on this one for the past few days. I am trying to incorporate googletest's gmock library into my Qt Autotest subdir project, but have been receiving the following linker error and I am unsure on how to resolve this. The main application compiles and runs perfectly fine.
tst_reptileprofile.obj : error LNK2019: unresolved external symbol "public: __thiscall DashboardWidget::DashboardWidget(void)" (??0DashboardWidget##QAE#XZ) referenced in function "private: void __thiscall TestReptileProfile::init(void)" (?init#TestReptileProfile##AAEXXZ)
Here is the test code:
#include <QtTest/QtTest>
#include <QCoreApplication>
#include <QObject>
#include "gmock/gmock.h"
#include "../Application/dashboardwidget.h"
class TestReptileProfile : public QObject
{
Q_OBJECT
public:
TestReptileProfile() {}
~TestReptileProfile() {}
private slots:
void initTestCase()
{
}
void cleanupTestCase()
{
}
void init()
{
dashboard_ = new DashboardWidget();
}
void cleanup()
{
delete dashboard_;
}
private:
DashboardWidget* dashboard_;
};
#include "tst_reptileprofile.moc"
QTEST_MAIN(TestReptileProfile)
DashboardWidget.h/.cpp
#pragma once
#include <QtWidgets/QWidget>
#include <QtWidgets/QAbstractButton>
namespace Ui {
class DashboardWidget;
}
class DashboardWidget : public QWidget
{
Q_OBJECT
public:
explicit DashboardWidget();
~DashboardWidget();
QAbstractButton* openProfileButton();
private:
Ui::DashboardWidget *ui;
QAbstractButton* openProfileButton_;
};
#include "dashboardwidget.h"
#include "ui_dashboardwidget.h"
DashboardWidget::DashboardWidget() :
ui(new Ui::DashboardWidget)
{
ui->setupUi(this);
openProfileButton_ = ui->openReptileProfilePageButton;
}
DashboardWidget::~DashboardWidget()
{
delete ui;
}
QAbstractButton* DashboardWidget::openProfileButton()
{
return openProfileButton_;
}
Subdirs Project .pro
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
Application \
AutoTests
AutoTests.depends = Application
Application.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Application
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
mainview.cpp \
. . .
mainpresenter.cpp \
dashboardwidget.cpp \
FORMS += \
mainview.ui \
i_mainpresenter.h \
dashboardwidget.ui \
HEADERS += \
mainview.h \
dashboardwidget.h \
AutoTests.pro
QT += testlib
QT += gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += qt warn_on depend_includepath testcase
TEMPLATE = app
SOURCES += \
tst_reptileprofile.cpp
unix|win32: LIBS += -L$$PWD/../../../googletest/googlemock/msvc/2015/Win32-Release/ -lgmock
INCLUDEPATH += $$PWD/../../../googletest/googlemock/msvc/2015/Win32-Release
DEPENDPATH += $$PWD/../../../googletest/googlemock/msvc/2015/Win32-Release
INCLUDEPATH += D:\googletest\googlemock\include\
INCLUDEPATH += D:\googletest\googletest\include\
I also tried converting the project into a Visual Studio project which causes a compilation error instead.
Error C2059 syntax error: '.' AutoTests ProjectDir\tst_reptileprofile.cpp 63
Thanks
There are two points. The first thing: you are creating two executables (application and AutoTest). To test your production code you have to build it into a library.
TEMPLATE = lib
That means, one should create two executables, for testing and for the application. The executables need to be linked against the new library.
e.g:
LIBS += -L../lib/debug -llib
At the end you have three subdirectories and .pro-files.
The second thing: The symbols in the library has to be exported if the library is created and imported when you are linking against the library. This can be done with the preprocessor definition: TEST_COMMON_DLLSPEC.
You find the complete how to in the following link:
https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application
This tutorial isn't with googletest but you can use it similar.
Good evening,
system: mac OSX 10.10.1
Qt 5.3.2 (via homebrew)
qwt 6.1.1 (via homebrew)
Qt Creator 3.2.1
I have used this tutorial http://codingexodus.blogspot.de/2013/01/getting-started-with-qwt.html and this one [http://de.wikibooks.org/wiki/Qt_für_C%2B%2B-Anfänger:_Qwt_nutzen2 as a starting point.
Here qwt is used in main.cpp:
#include <qwt_plot_curve.h>
#include <qwt_plot.h>
#include <qapplication.h>
int main(int argc, char **argv)
{
QApplication a(argc, argv);
double x[101];
double y[101];
for ( int i = 0; i < 101; i++ ) {
x[i] = i / 10.0;
y[i] = sin(x[i]);
}
QwtPlot plot;
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setRawSamples(x, y, 101);
curve->attach(&plot);
plot.show();
return a.exec();
}
When I tried (via copy and paste for test purposes if I have the library included correctly) the codes from both sites I kept receiving
QWidget: Must construct a QApplication before a QPaintDevice
Ok, so I should create a Application before I create a Widget.
However, to be on the safe side, I decided to test puting the qwt part into the mainwindow .cpp file. Still, no success.
Below the application output. Seems like there is some conflict between qwt and qt... (does not appear, when I do not use qwt).
Starte /Users/axel/Programmierung/Qt/Qwt2/build-Qwt2-Desktop-Debug/Qwt2.app/Contents/MacOS/Qwt2...
objc[6955]: Class QCocoaPageLayoutDelegate is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport. One of the two will be used. Which one is undefined.
objc[6955]: Class QCocoaPrintPanelDelegate is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport. One of the two will be used. Which one is undefined.
objc[6955]: Class QCocoaApplicationDelegate is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/plugins/platforms/libqcocoa.dylib. One of the two will be used. Which one is undefined.
objc[6955]: Class QNSApplication is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/plugins/platforms/libqcocoa.dylib. One of the two will be used. Which one is undefined.
objc[6955]: Class QCocoaMenuLoader is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/plugins/platforms/libqcocoa.dylib. One of the two will be used. Which one is undefined.
objc[6955]: Class QNSOpenSavePanelDelegate is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/plugins/platforms/libqcocoa.dylib. One of the two will be used. Which one is undefined.
objc[6955]: Class QNSImageView is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/plugins/platforms/libqcocoa.dylib. One of the two will be used. Which one is undefined.
objc[6955]: Class QNSStatusItem is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/plugins/platforms/libqcocoa.dylib. One of the two will be used. Which one is undefined.
objc[6955]: Class QNSMenu is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/plugins/platforms/libqcocoa.dylib. One of the two will be used. Which one is undefined.
QWidget: Must construct a QApplication before a QPaintDevice
Das Programm ist abgestürzt.
/Users/axel/Programmierung/Qt/Qwt2/build-Qwt2-Desktop-Debug/Qwt2.app/Contents/MacOS/Qwt2 ist abgestürzt
qwt2.pro
#-------------------------------------------------
#
# Project created by QtCreator 2014-12-06T23:33:01
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Qwt2
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../usr/local/Cellar/qwt/6.1.1/lib/release/ -lqwt
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../usr/local/Cellar/qwt/6.1.1/lib/debug/ -lqwt
else:mac: LIBS += -F$$PWD/../../../../../../usr/local/Cellar/qwt/6.1.1/lib/ -framework qwt
else:unix: LIBS += -L$$PWD/../../../../../../usr/local/Cellar/qwt/6.1.1/lib/ -lqwt
INCLUDEPATH += $$PWD/../../../../../../usr/local/Cellar/qwt/6.1.1/lib/qwt.framework/Versions/6/Headers
DEPENDPATH += $$PWD/../../../../../../usr/local/Cellar/qwt/6.1.1/lib/qwt.framework/Versions/6/Headers
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <qwt_plot_curve.h>
#include <qwt_plot.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);
double x[101];
double y[101];
for ( int i = 0; i < 101; i++ ) {
x[i] = i / 10.0;
y[i] = sin(x[i]);
}
QwtPlot plot;
// QwtPlotCurve *curve = new QwtPlotCurve();
// curve->setRawSamples(x, y, 101);
// curve->attach(&plot);
// plot.show();
}
MainWindow::~MainWindow()
{
delete ui;
}
(note that the error regarding QApplication and QPaintDevice is replicated as soon as I remove the comment before QwtPlot plot;.
Additional info from 07.12.2014
Please note that the error messages hint at a different Qt version:
objc[8714]: Class QNSMenu is implemented in both /usr/local/lib/QtGui.framework/Versions/4/QtGui and /usr/local/Cellar/qt5/5.3.2/plugins/platforms/libqcocoa.dylib. One of the two will be used. Which one is undefined.
I did not install Qt4 (knowingly)
Hypothesis:
Homebrew installed Qt4.
So i checked via brew info qwt.
Answer: ==> Dependencies
Required: qt ✔
So next step: brew info qt
Answer:
qt: stable 4.8.6 (bottled), HEAD
http://qt-project.org/
/usr/local/Cellar/qt/4.8.6 (2790 files, 122M) *
Built from source
Ok, so homebrew installs Qt4 for qwt.
I vaguely remember that in 5.1 or 5.2 Qt moved some QGui or QApplication stuff to another header... So if qwt now chooses a header from Qt5 (remember: the error message said this is undefined behaviour) instead of Qt4, could this explain why the error occurs?
Ok, by now I opened a new project with the same source code but using qt 4.8.6.
No error messages.
Also no plot, but this seems to be another problem.
I have been migrating from Qt 4.8.5 to Qt 5.3.0 recently, and these are the related information:
Windows 7 32 bit
Qt 3.1.1
MSVC 2010 compiler (Both my Qt versions are pre-compiled package of MSVC2010 edition)
debugger from Win7 SDK
Now I've been trapped by a problem that I keep getting compilation errors:
fatal error C1083: Cannot open include file
from those header files inside subdirectories, for example, #include "FooFolder/bar.h".
The compiler is unable to locate all this kind of headers and I am totally befuddled since:
The Intellisense works well.
If I change back to old kit Qt 4.8.5, it compiles fine
Both kits use the same MSVC compiler.
Here is my .pro file:
QT += core gui script
QT += printsupport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyApp
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
qcustomplot.cpp \
dialogs/filterdialog.cpp \
databox/databox.cpp \
databox/datom.cpp \
#... and more FooFolder/bar.cpp
HEADERS += mainwindow.h \
qcustomplot.h \
dialogs/filterdialog.h \
databox/databox.h \
databox/datom.h \
#... and more FooFolder/bar.h
RESOURCES += \
resources.qrc
win32: LIBS += -LC:/ADLINK/UDASK/lib/ -lusb-dask \
INCLUDEPATH += C:/ADLINK/UDASK/include \
DEPENDPATH += C:/ADLINK/UDASK/include \
include(qext/qextserialport.pri)
and here is one of the .h file that files to include other subdirectoried headers
#ifndef SETWINDOW_H
#define SETWINDOW_H
#include <QObject>
#include "databox/databox.h" // <---fatal error C1083: Cannot open include file
class SetWindow: public QObject
{
Q_OBJECT
public:
SetWindow();
public Q_SLOTS:
void setPointNum(int n);
void setStepSize(int s);
int getPointNum();
int getStepSize();
void requestSignal();
Q_SIGNALS:
void sendParameters(int p, int s);
private:
QString DynamicString;
DataBox *presentData;
int m_PointNum;
int m_StepSize;
};
#endif // SETWINDOW_H
and the header file failed to be included:
#ifndef DATABOX_H
#define DATABOX_H
#include <QVector>
#include <QFile>
#include <QMap>
#include <QString>
#include "datom.h"
class Measurement
{
public:
Measurement();
void setNumChan(int n);
void setADRange(QString &s);
void setSamplingRate(int n);
void setTimeBase(double d);
int NumChan;
QString ADRange;
int SamplingRate;
double TimeBase;
};
class DataBox
{
public:
DataBox();
void setCurrentFile(QString path);
void loadData();
void cleanAll();
QVector<double>* py_0;
QVector<double>* py_1;
QVector<double>* ptimeStamp;
QVector<double>* pi_M;
QVector<double>* py_M;
QVector<double>* py_W;
QMap<double, double> AI_0;
QMap<double, double> AI_1;
QMap<int, double> AI0;
QMap<int, double> AI1;
double timeBase;
Measurement parameters;
QVector<Datom> *dataPoints;
private:
QString currentFile;
};
#endif // DATABOX_H
These seem to be incorrect:
win32: LIBS += -LC:/ADLINK/UDASK/lib/ -lusb-dask \
INCLUDEPATH += C:/ADLINK/UDASK/include \
DEPENDPATH += C:/ADLINK/UDASK/include \
1) \ means it joins the next line which is not what you wish. It is not an issue for the lines with followed empty line, but it is not good for the INCLUDEPATH in here, and if you replace the empty lines with some containment, you could run into issues with the other lines, too.
2) You will also need to put $$PWD into the includepath to get the project root "registered" since your include should start from there, not the current working directory of the source since that is not the right route as you can assume.
Therefore, you would be writing something like this:
win32: LIBS += -LC:/ADLINK/UDASK/lib/ -lusb-dask
INCLUDEPATH += $$PWD C:/ADLINK/UDASK/include
DEPENDPATH += C:/ADLINK/UDASK/include