Build and installation
qmake qwt.pro
make
sudo make install
Configure
2.1. add the following lines to .bashrc:
export QWT_ROOT="/usr/local/qwt-6.2.0"
QT_PLUGIN_PATH="${QWT_ROOT}/plugins:$QT_PLUGIN_PATH"
export QT_PLUGIN_PATH
2.2. add the line to /etc/ld.so.conf.d/qwt.conf: /usr/local/qwt-6.2.0/lib
Imput to console: qmake -set QMAKEFEATURES ${QWT_ROOT}/features
Create project
DeleteMe.pro
QT += quick
#add QWT
CONFIG += qwt
INCLUDEPATH += /usr/local/qwt-6.2.0/include
LIBS += -L/usr/local/qwt-6.2.0/lib -lqwt
SOURCES += \
main.cpp
...
main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QwtPlot>
#include <QwtText>
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QwtPlot plot(QwtText("Qwt example"));
plot.setGeometry(0,0,640, 300);
plot.show();
return 0;
}
When I compile, i got the errors:
:-1: error: main.o: undefined reference to symbol '_ZN7QWidget4showEv##Qt_5'
:-1: error: /lib/x86_64-linux-gnu/libQt5Widgets.so.5: error adding symbols: DSO missing from command line
Please help me to run the program
Related
Recently build OPENCV 3.4.3 with CMAKE 3.12.4 and MINGW64(32bit) 8.1.0 in Windows 7. Have QT 5.6 and i trying to test this build as QT Console App, but when i compiling with QT only get the message "Press "RETURN" to close this window...".
.PRO file:
CONFIG += c++11
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES += test.png
INCLUDEPATH += C:\Users\Test\Desktop\opencv\build\include
LIBS += C:\Users\Test\Desktop\mingw\bin\libopencv_*.dll
main.cpp:
#include <QCoreApplication>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
using namespace std;
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
cout << "Hello World!" << endl;
cv::Mat mat;
mat = cv::imread("test.png");
cvNamedWindow("hello");
cv::imshow("hello",mat);
return a.exec();
}
What im doing wrong?
Imo the problem is not in your code, I just run it (using Qt5.5, Win10, openCV 4 and mingw64), even if I had to change cvNamedWindow to cv::namedWindow.
I have two hints:
did you build openCV with mingw64? If not, do so.
are the openCV dlls in the path when you run the application? You can also copy all opencv dlls in the program folder to check that quickly...
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.
My goal is to run a simple OpenCV contribute (extra) module in Qt 5.5.1.
Steps:
1) created a Qt Application app;
2) changed the main.cpp file to :
#include <QApplication>
#include <opencv2/core/utility.hpp>
#include <opencv2/tracking.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <cstring>
#include <QDebug>
using namespace std;
using namespace cv;
int main(int argc, char*argv[])
{
qDebug() <<"start!" << endl;
QApplication a(argc, argv);
string trackingAlg = "KCF";
MultiTracker trackers(trackingAlg);
qDebug() <<"success!" << endl;
return a.exec();
}
and here is my .pro file:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = tracker4
CONFIG += c++11
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/local/include/opencv
LIBS += `pkg-config opencv --libs`
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_videoio -lopencv_tracking
The program compiles successfully, but in the runtime, it crashes without even running the main() function. I don't get such an error when I run this in Code::Blocks but in Qt I still have this issue.
I am using Qt 5.5.1 and Ubuntu 14.04.
Can anyone generate this "seg fault" error in his/her machine?
For QT 5, build the OpenCV with QT=OFF.
For QT 4, build the OpenCV with QT=ON.
I tried to use libjpeg-turbo with qt.
I downloaded libjpeg-turbo and installed. I wanted to use it within a project but I got the following fault:
C:\libjpeg-turbo-gcc64\bin\libjpeg-62.dll:-1: Error: file not
recognized: File format not recognized
As soon as I removed the libjpeg-62.dll I received the following fault:
C:\test\main.cpp:8: Error: undefined reference to
`tjInitCompress'
Why is the libjpeg-62 not recognizing the file format?
Thanks for help,
Willy
PS. Here is the code:
test.pro
QT += core
QT -= gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\libjpeg-turbo-gcc64\include
LIBS += -LC:\libjpeg-turbo-gcc64\bin -llibjpeg-62
main.cpp
#include <QCoreApplication>
#include <turbojpeg.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
tjhandle _jpegCompressor = tjInitCompress();
return a.exec();
}
Ok now it works,
it was the wrong version of libjpeg-turbo. Now I use the libjpeg-turbo-gcc and not the libjpeg-turbo-gcc64. Also i change the Libs-Path to
LIBS += "C://libjpeg-turbo-gcc64//bin//libjpeg-62.dll"
MfG Willy
I'm trying to get the following c++ program using Qwt v. 6.0.1 to work:
#include <cmath>
#include <QApplication>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
int main(int argc, char **argv)
{
QApplication a(argc, argv);
QwtPlot plot(QwtText("CppQwtExample1"));
plot.setGeometry(0,0,640,400);
plot.setAxisScale(QwtPlot::xBottom, 0.0, 2.0*M_PI);
plot.setAxisScale(QwtPlot::yLeft, -1.0, 1.0);
QwtPlotCurve sine("Sine");
std::vector<double> xs;
std::vector<double> ys;
for (double x=0; x<2.0*M_PI; x+=(M_PI/10.0)) {
xs.push_back(x);
ys.push_back(std::sin(x));
}
sine.setData(&xs[0], &ys[0], xs.size());
sine.attach(&plot);
plot.show();
return a.exec();
}
and the .pro file looks like:
TEMPLATE = app
TARGET = CppQwtExample1
QMAKEFEATURES += /usr/local/qwt-6.0.1/features
CONFIG += qwt
INCLUDEPATH += /usr/local/qwt-6.0.1/lib/qwt.framework/Headers
LIBS += -L/usr/local/qwt-6.0.1/lib/qwt.framework/Versions/6/ \
-lqwt
SOURCES += qwtTest.cpp
However, when I now try to do
qmake
make
I get the error:
ld: library not found for -lqwt
collect2: ld returned 1 exit status
make: * [qwtTest.app/Contents/MacOS/qwtTest] Error 1
I surely miss something here. Any help is greatly appreciated.
LIBS += -L/usr/local/qwt-6.0.1/lib/qwt.framework/Versions/6/ -lqwt
This is wrong. Due to the naming conventions of Mac OS X frameworks, the dynamic library inside qwt.framework isn't named "libqwt.dylib" (which the linker requires), but simply "qwt".
Use
LIBS += -F/usr/local/qwt-6.0.1/lib -framework qwt
instead.