PDA

View Full Version : First Project with Qwt - qwt_plot.h: No such file or directory



metRo_
9th November 2010, 00:49
I have downloaded Qwt and did qmake, make, make install.
Create a project basead in that: http://www.body-sensing.com/index.php?option=com_content&view=article&id=5:display-curves-with-a-qt-application&catid=5:divers&Itemid=6

This is what i have:
http://img130.imageshack.us/img130/7650/projectstruct.png
http://img301.imageshack.us/img301/5798/filesstruct.png

and this is the code:
testeempty.pro

SOURCES += \
main.cpp \
dataplot.cpp

HEADERS += \
dataplot.h

QWT_DIR = /qwt-521
INCLUDEPATH += $$QWT_DIR/include

CONFIG(debug, debug|release):LIBS += -L$$QWT_DIR\lib\ \
-lqwtd5
else:LIBS += -L$$QWT_DIR\lib\ \
-lqwt5

DEFINES += QWT_DLL

dataplot.h

#ifndef DATAPLOT_H
#define DATAPLOT_H

#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_array.h>
#include <qwt_math.h>


class CurveData
{
public:
CurveData( int size );
const double *x() const;
const double *y() const;
QwtArray<double> d_x;
QwtArray<double> d_y;
};


class DataPlot : public QwtPlot
{
public:
DataPlot( QWidget* = NULL );
QwtPlotCurve* curve;
};


#endif // DATAPLOT_H

dataplot.cpp

#include "dataplot.h"


CurveData::CurveData( int size )
{
d_x.resize( size );
d_y.resize( size );
// Initialize data
for (int i = 0; i< size; i++)
{
d_x[i] = 0.5 * i; // time axis
d_y[i] = 0;
}
}


const double *CurveData::x() const
{
return d_x.data();
}


const double *CurveData::y() const
{
return d_y.data();
}


DataPlot::DataPlot( QWidget* parent ): QwtPlot( parent )
{
setAxisScale( yLeft , -1 , 1 );
// Create curve
curve = new QwtPlotCurve();
curve->attach( this );
}

main.cpp

#include <QApplication>
#include <QMainWindow>
#include "dataplot.h"


const int PLOT_SIZE = 201;


class MainWindow : public QMainWindow
{
public:
MainWindow()
{
data = new CurveData( PLOT_SIZE );
plot = new DataPlot;
plot->setTitle( QString("Simple Qwt Usage") );
plot->curve->setRawData( data->x() , data->y() , PLOT_SIZE );
setCentralWidget( plot );
startTimer( 20 );
}
private:
DataPlot* plot;
CurveData* data;
virtual void timerEvent( QTimerEvent* e );
};


void MainWindow::timerEvent( QTimerEvent* )
{
static double phase = 0.0;
for ( int i = PLOT_SIZE - 1; i > 0; i-- )
data->d_y[i] = data->d_y[i-1];
data->d_y[0] = sin( phase );
plot->replot();
phase += M_PI * 0.02;
}


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow mw;
mw.resize(500,300);
mw.show();
return a.exec();
}

And the now the error:

Running build steps for project testeempty...
Configuration unchanged, skipping qmake step.
Starting: "/usr/bin/make" -w
make: Entering directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
/usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile ../testeempty/testeempty.pro
WARNING: /home/ze/Documentos/Qt/testeempty/testeempty.pro:13: Unescaped backslashes are deprecated.
make: Leaving directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
make: Entering directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQWT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../testeempty -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/qwt-521/include -I. -I../testeempty -I. -o main.o ../testeempty/main.cpp
In file included from ../testeempty/main.cpp:3:
../testeempty/dataplot.h:4: fatal error: qwt_plot.h: No such file or directory
compilation terminated.
make: Leaving directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
make: *** [main.o] Error 1
The process "/usr/bin/make" exited with code %2.
Error while building project testeempty (target: Desktop)
When executing build step 'Make'


Can anyone help me?!

Uwe
9th November 2010, 07:29
Obviously you didn't install to /qwt-521. When you didn't change qwtconfig.pri manually Qwt should have been installed to /usr/local/qwt-5.2.1.

Uwe

metRo_
9th November 2010, 11:53
thanks, now it can found it :) but give another errors:


Running build steps for project testeempty...
Starting: "/usr/bin/make" clean -w
make: Entering directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
/usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile ../testeempty/testeempty.pro
WARNING: /home/ze/Documentos/Qt/testeempty/testeempty.pro:13: Unescaped backslashes are deprecated.
make: Leaving directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
make: Entering directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
rm -f main.o dataplot.o
rm -f *~ core *.core
make: Leaving directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
The process "/usr/bin/make" exited normally.
Configuration unchanged, skipping qmake step.
Starting: "/usr/bin/make" -w
make: Entering directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQWT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../testeempty -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/usr/local/qwt-5.2.1/include -I. -I../testeempty -I. -o main.o ../testeempty/main.cpp
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQWT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../testeempty -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I/usr/local/qwt-5.2.1/include -I. -I../testeempty -I. -o dataplot.o ../testeempty/dataplot.cpp
g++ -o testeempty main.o dataplot.o -L/usr/lib -L/usr/local/qwt-5.2.1\lib\ -lqwtd5 -lQtGui -lQtCore -lpthread
main.o: In function `MainWindow':
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/main.cpp:16: undefined reference to `QwtPlot::setTitle(QString const&)'
make: Leaving directory `/home/ze/Documentos/Qt/testeempty-build-desktop'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/main.cpp:17: undefined reference to `QwtPlotCurve::setRawData(double const*, double const*, int)'
dataplot.o: In function `DataPlot':
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:29: undefined reference to `QwtPlot::QwtPlot(QWidget*)'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:31: undefined reference to `QwtPlot::setAxisScale(int, double, double, double)'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:33: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:34: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:35: undefined reference to `QwtPlot::~QwtPlot()'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:29: undefined reference to `QwtPlot::QwtPlot(QWidget*)'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:31: undefined reference to `QwtPlot::setAxisScale(int, double, double, double)'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:33: undefined reference to `QwtPlotCurve::QwtPlotCurve()'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:34: undefined reference to `QwtPlotItem::attach(QwtPlot*)'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.cpp:35: undefined reference to `QwtPlot::~QwtPlot()'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x8): undefined reference to `QwtPlot::metaObject() const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0xc): undefined reference to `QwtPlot::qt_metacast(char const*)'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x10): undefined reference to `QwtPlot::qt_metacall(QMetaObject::Call, int, void**)'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x1c): undefined reference to `QwtPlot::event(QEvent*)'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x40): undefined reference to `QwtPlot::sizeHint() const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x44): undefined reference to `QwtPlot::minimumSizeHint() const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x84): undefined reference to `QwtPlot::resizeEvent(QResizeEvent*)'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0xe0): undefined reference to `QwtPlot::print(QPainter*, QRect const&, QwtPlotPrintFilter const&) const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0xe4): undefined reference to `QwtPlot::canvasMap(int) const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0xe8): undefined reference to `QwtPlot::polish()'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0xec): undefined reference to `QwtPlot::updateLayout()'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0xf0): undefined reference to `QwtPlot::drawCanvas(QPainter*)'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0xf4): undefined reference to `QwtPlot::clear()'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0xf8): undefined reference to `QwtPlot::replot()'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0xfc): undefined reference to `QwtPlot::legendItemClicked()'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x100): undefined reference to `QwtPlot::legendItemChecked(bool)'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x104): undefined reference to `QwtPlot::drawItems(QPainter*, QRect const&, QwtScaleMap const*, QwtPlotPrintFilter const&) const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x108): undefined reference to `QwtPlot::updateTabOrder()'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x10c): undefined reference to `QwtPlot::printLegendItem(QPainter*, QWidget const*, QRect const&) const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x110): undefined reference to `QwtPlot::printTitle(QPainter*, QRect const&) const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x114): undefined reference to `QwtPlot::printScale(QPainter*, int, int, int, int, QRect const&) const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x118): undefined reference to `QwtPlot::printCanvas(QPainter*, QRect const&, QRect const&, QwtScaleMap const*, QwtPlotPrintFilter const&) const'
dataplot.o:(.rodata._ZTV8DataPlot[vtable for DataPlot]+0x11c): undefined reference to `QwtPlot::printLegend(QPainter*, QRect const&) const'
dataplot.o:(.rodata._ZTI8DataPlot[typeinfo for DataPlot]+0x8): undefined reference to `typeinfo for QwtPlot'
dataplot.o: In function `~DataPlot':
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.h:22: undefined reference to `QwtPlot::~QwtPlot()'
/home/ze/Documentos/Qt/testeempty-build-desktop/../testeempty/dataplot.h:22: undefined reference to `QwtPlot::~QwtPlot()'
collect2: ld returned 1 exit status
make: *** [testeempty] Error 1
The process "/usr/bin/make" exited with code %2.
Error while building project testeempty (target: Desktop)
When executing build step 'Make'

metRo_
9th November 2010, 23:03
I added this: LIBS += -L /usr/local/qwt-5.2.1/lib/ -lqwt and now it compile :) but when it go to execute it said:
Starting /home/ze/Documentos/Qt/testeempty-build-desktop/testeempty...
/home/ze/Documentos/Qt/testeempty-build-desktop/testeempty: error while loading shared libraries: libqwt.so.5: cannot open shared object file: No such file or directory
/home/ze/Documentos/Qt/testeempty-build-desktop/testeempty exited with code 127

so i need to open a console at /home/ze/Documentos/Qt/testeempty-build-desktop/ and run export LD_LIBRARY_PATH=/usr/local/qwt-5.2.1/lib/ and after if i run ./testeempty it works :)

What i need to add to my qt project file to avoid to do this: export LD_LIBRARY_PATH=/usr/local/qwt-5.2.1/lib/ !?

Uwe
10th November 2010, 06:34
Nothing instead you have to understand how shared libraries work. F.e. read about ldconfig.

Uwe

metRo_
10th November 2010, 15:39
Bu i don't want to need to add the path to ldconfig instead this is the last option. What i want is to have all the files,libraries in the same folder, and can change the folder between pcs without need to add the path to ldconfig!