Encoding error in QT Creator when including glm header files - c++

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.

Related

Undefined reference error when linking dynamic and static libraries consequently

I have a QT project with 4 subprojects with the following names: exec (executable), sharedlib (dynamic library), sharedlib2 (other one dynamic library) and staticlib. All this is linked consequently as follows:
exec->sharedlib2->sharedlib->staticlib
In the static library is defined Staticlib class.
Now, when compiling all of this, I'm getting undefined reference error when trying to use that class (in exec project, main.cpp):
/home/user/temp/libproj/libproj/exec/main.cpp:9: error: undefined reference to `Staticlib::Staticlib()'
What am I doing wrong?
staticlib.h:
#ifndef STATICLIB_H
#define STATICLIB_H
#include <QDebug>
class Staticlib
{
public:
Staticlib();
void debugprint();
};
#endif // STATICLIB_H
sharedlib.pro:
QMAKE_LFLAGS += -Wl,--whole-archive,--allow-multiple-definition
LIBS += -L$$OUT_PWD/../staticlib/
LIBS += -lstaticlib
sharedlib2.pro:
LIBS += -L$$OUT_PWD/../sharedlib/
LIBS += -lsharedlib
exec.pro:
INCLUDEPATH += $$PWD/../staticlib
#doesnt work
LIBS += -L$$OUT_PWD/../sharedlib2
LIBS += -lsharedlib2
#works well
#//LIBS += -L$$OUT_PWD/../sharedlib/
#//LIBS += -lsharedlib
exec, main.cpp:
#include <QCoreApplication>
#include "staticlib.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Staticlib statlib;
statlib.debugprint();
return a.exec();
}
staticlib.pro
QT -= gui
TEMPLATE = lib
CONFIG += staticlib
CONFIG += c++17
SOURCES += \
staticlib.cpp
HEADERS += \
staticlib.h
staticlib.cpp
#include "staticlib.h"
#include <QDebug>
Staticlib::Staticlib()
{
}
void Staticlib::debugprint()
{
qDebug() << "Staticlib::debugprint()";
}

no such file or directory [duplicate]

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?

LNK2019 With Qt and Gmock [duplicate]

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.

C++ Octave in QtCreator (windows)

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 ...

Unable to locate the header files inside subdirectories while migrating to Qt5

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