Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QwtPlot3d Linux
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QwtPlot3d Linux

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 10.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    avmg
    wrote on last edited by
    #4

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #5

      Hi,

      How did you setup the library ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        avmg
        wrote on last edited by
        #6

        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 to gluNewQuadric'
        /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 to gluUnProject'
        /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 to gluQuadricDrawStyle'
        /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 to gluCylinder'
        /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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #7

          Then you need to link to glut by hand

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            avmg
            wrote on last edited by
            #8

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

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #9

              Your pro file

              @
              LIBS += -lglu
              @

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                avmg
                wrote on last edited by
                #10

                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 to gluNewQuadric'
                /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 to gluUnProject'
                /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 to gluQuadricDrawStyle'
                /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 to gluCylinder'
                /home/amg/Qt/build-qwtplot3d-Qt_5_2_0_gcc_64-Debug/lib/release/linux/libqwtplot3d.so: undefined reference to `gluProject'

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

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

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    avmg
                    wrote on last edited by
                    #12

                    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?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      avmg
                      wrote on last edited by
                      #13

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

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        avmg
                        wrote on last edited by
                        #14

                        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!

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #15

                          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 :)

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved