[SOLVED] QwtPlot3d Linux



  • Hi,

    I downloaded the QwtPlot3d feature but at the moment it doesn't work for me. I try to run the examples, and also i tried to add the include files to a new project but at the end the errors are same. Looks like they are related with some "glu" library, this is one of the errors:

    error: 'gluErrorString' was not declared in this scope

    I found some instructions to use QwtPlot3d in windows but nothing for Linux. I also don't know if i need to install some "OpenGL" staff or whatever...

    I saw many people with this problem but i couldn't find any answer or solution yet.

    Any suggestion???

    Thanks,
    Andrew


  • Moderators

    Hi,

    Yes QwtPlot3D "requires OpenGL 1.1 or higher":http://qwtplot3d.sourceforge.net/. You will need to install OpenGL development libraries.



  • Ok, I will try it.

    Thanks



  • Hi again,

    I installed OpenGL as you recomend me but now when i create a Plot3D i get this error:

    error: undefined reference to `Qwt3D::Plot3D::Plot3D(QWidget*, QGLWidget const*)'
    File not found: "path from the Form1.cpp"

    This is how i have created the plot:

    @
    //Form1.h
    public:
    Qwt3D::Plot3D *plot;

    //Form1.cpp
    QGridLayout *grid = new QGridLayout( );
    plot = new Plot3D();
    grid->addWidget( plot, 0, 0 );
    @

    Thanks,
    Andrew


  • Lifetime Qt Champion

    Hi,

    How did you setup the library ?



  • Hi!

    First thing I did after downloading the library was build "qwtplot3d.pro" and get these dynamic libraries:

    libqwtplot3d.so
    libqwtplot3d.so.0
    libqwtplot3d.so.0.3
    libqwtplot3d.so.0.3.0

    Then I use them for the new projects, or starting simply, let's try with the examples. So I open the example "simpleplot" with the next files, and I modify the common.pro file to add the libraries:

    simpleplot.cpp:
    @
    #include <math.h>
    #include "/home/amg/Qt/5.3/gcc_64/include/QtWidgets/qapplication.h"
    #include <qwt3d_plot.h>
    #include <qwt3d_curve.h>
    #include <qwt3d_color.h>
    #include <qwt3d_function.h>

    using namespace Qwt3D;

    class Rosenbrock : public Function
    {
    public:

    Rosenbrock(Curve& pw)
    :Function(pw)
    {
    }
    
    double operator()(double x, double y)
    {
      return log((1-x)*(1-x) + 100 * (y - x*x)*(y - x*x)) / 8;
    }
    

    };

    class RosenbrockNegative : public Function
    {
    public:

    RosenbrockNegative(Curve& pw)
    :Function(pw)
    {
    }
    
    double operator()(double x, double y)
    {
      return -1.0 * (log((1-x)*(1-x) + 100 * (y - x*x)*(y - x*x)) / 8);
    }
    

    };

    class Plot : public Plot3D
    {
    public:
    Plot();
    private:
    Curve* curve_p;
    Curve* curve_p2;
    };

    Plot::Plot()
    {
    curve_p = new Curve(this);
    addCurve(curve_p);
    Rosenbrock rosenbrock(*curve_p);

    rosenbrock.setMesh(41,31);
    rosenbrock.setDomain(-1.73,1.5,-1.5,1.5);
    rosenbrock.setMinZ(-10);
    
    rosenbrock.create();
    
    setTitle("A Simple SurfacePlot Demonstration");
    
    curve_p2 = new Curve(this);
    addCurve(curve_p2);
    RosenbrockNegative rosenbrockNegative(*curve_p2);
    
    rosenbrockNegative.setMesh(41,31);
    rosenbrockNegative.setDomain(-1.73,1.5,-1.5,1.5);
    rosenbrockNegative.setMinZ(-10);
    
    rosenbrockNegative.create();
    
    setRotation(30,0,15);
    setScale(1,1,1);
    setShift(0.15,0,0);
    setZoom(0.9);
    
    for (unsigned i=0; i!=coordinates()->axes.size(); ++i)
    {
      coordinates()->axes[i].setMajors(7);
      coordinates()->axes[i].setMinors(4);
    }
    
    
    coordinates()->axes[X1].setLabelString("x-axis");
    coordinates()->axes[Y1].setLabelString("y-axis");
    //coordinates()->axes[Z1].setLabelString(QChar(0x38f)); // Omega - see http://www.unicode.org/charts/
    
    
    setCoordinateStyle(BOX);
    

    // comment out the next line to use default single legend mode
    setDoubleLegend(); // setup the default colour legend mode

    //setup the multi-curve colour legends
    curve_p->setColorLegend(0, isDoubleLegend(),
    isDoubleLegend() ? QSize(2,28) : QSize(3,32),
    isDoubleLegend() ? QPoint(7,10) : QPoint(3,10));
    curve_p2->setColorLegend(1, isDoubleLegend(),
    isDoubleLegend() ? QSize(2,28) : QSize(3,32),
    isDoubleLegend() ? QPoint(7,10) : QPoint(3,10));

    showColorLegend(true); // show the actual curve legends

    updateData();
    updateGL();
    

    }

    int main(int argc, char **argv)
    {
    QApplication a(argc, argv);
    Plot plot;
    #if QT_VERSION < 0x040000
    a.setMainWidget(&plot);
    #endif
    plot.resize(800,600);
    plot.show();
    return a.exec();
    }
    @

    simpleplot.pro:
    @
    include( ../common.pri )
    SOURCES = simpleplot.cpp
    @

    common.pri
    @
    TEMPLATE = app
    CONFIG += qt warn_on thread release
    UI_DIR = tmp
    MOC_DIR = tmp
    OBJECTS_DIR = tmp
    INCLUDEPATH += ../../include
    DEPENDPATH = $$INCLUDEPATH
    DESTDIR = ../bin

    unix:LIBS += -L/home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux -lqwtplot3d

    linux-g++:QMAKE_CXXFLAGS += -fno-exceptions

    CONFIG(debug, debug|release) {
    DESTDIR = ../bin/debug
    } else {
    DESTDIR = ../bin/release
    }

    Choose +/- on the following line to show/hide debug output relating to library branch code

    DEFINES -= QT_NO_DEBUG_OUTPUT

    win32 {
    win32-g++ {
    LIBS += ../../lib/qwtplot3d.dll
    } else {
    LIBS += ../../lib/qwtplot3d.lib
    TEMPLATE = vcapp
    CONFIG(debug, debug|release) {
    QMAKE_LFLAGS += /NODEFAULTLIB:msvcrt
    }
    }
    DEFINES += QT_DLL QWT3D_DLL
    RC_FILE = ../icon.rc
    }

    MYVERSION = $$[QMAKE_VERSION]
    ISQT4 = $$find(MYVERSION, ^[2-9])

    !isEmpty( ISQT4 ) {
    RESOURCES = ../images.qrc
    QT += opengl
    }

    isEmpty( ISQT4 ) {
    CONFIG += opengl
    }
    @

    The only thing i change was the next line:
    @unix:LIBS += -L/home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux -lqwtplot3d@

    Because by default is like this...:
    @unix:LIBS += -lqwtplot3d -L../../lib@

    And also i modified some includes which were not detected. The errors i get are:

    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to gluDisk' /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference togluNewQuadric'
    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to gluQuadricOrientation' /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference togluUnProject'
    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to gluQuadricNormals' /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference togluQuadricDrawStyle'
    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to gluDeleteQuadric' /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference togluCylinder'
    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to `gluProject'

    These funcionts belongs to glu.h. I saw also in similar cases that there's not openGL/Glut library linked to project.

    But i tried many things but i'm not sure where is the problem...

    Thanks,
    Andrew


  • Lifetime Qt Champion

    Then you need to link to glut by hand



  • I saw something like adding -lGL -lGLU, but i don't where and how...


  • Lifetime Qt Champion

    Your pro file

    @
    LIBS += -lglu
    @



  • I checked where are the libraries and i add:

    @unix:LIBS += -L/usr/lib/x86_64-linux-gnu/mesa/ -lglu@

    and also i tried with:

    @unix:LIBS += -L/usr/lib/x86_64-linux-gnu -lGLU@

    ..because the files are named libGLU.so, but didn't work. In the second case i get these errors:

    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to gluDisk' /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference togluNewQuadric'
    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to gluQuadricOrientation' /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference togluUnProject'
    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to gluQuadricNormals' /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference togluQuadricDrawStyle'
    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to gluDeleteQuadric' /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference togluCylinder'
    /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to `gluProject'


  • Lifetime Qt Champion

    What do you get if you run ldd libqwtplot3d.so ?



  • If I run it in a terminal it says that the file doesn't exist... Do I need to run it in its file location?



  • Now i build qwtplot3d in a terminal:

    @cd qwtplot3d; qmake && make; cd ..
    @

    I get new libraries, i added them:

    @unix:LIBS += -L/home/amg/Qt/qwtplot3d/lib/release/unix -lqwtplot3d
    unix:LIBS += -L/usr/lib/x86_64-linux-gnu -lGLU@

    And now i get these errors:

    /usr/bin/ld: /home/amg/Qt/qwtplot3d/lib/release/unix/libqwtplot3d.a(gl2ps.o): undefined reference to symbol 'compress'
    //lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status

    'compress' i guess is from zlib compressor needed for the qwt3dplot, but i already install...



  • SOLVED!

    I was adding the LIBS in different lines. I put the compressor, the qwt3dplot and glu libraries in the same command and finally it worked!!!

    @unix:LIBS += -L/home/amg/Qt/qwtplot3d/lib/release/unix -lqwtplot3d -lz -lGLU@

    Thanks!


  • Lifetime Qt Champion

    You can use multiple lines without any problem, just ensure you are writing it right.

    @
    unix {
    LIBS += -L/home/amg/Qt/qwtplot3d/lib/release/unix
    -lqwtplot3d

    LIBS += -lz -lGLU
    }
    @

    Since it's solved now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.