Important: Please read the Qt Code of Conduct -

DeclarativeSurface - undefined reference

  • I am building an application that utilizes the undocumented DeclarativeSurface class, but having link problems. DeclarativeSurface is defined in 5.14.2/Src/qtdatavis3d/src/datavisualizationqml2/declarativesurface_p.h. I see DeclarativeSurface code in library qml/QtDataVisualization/, e.g. with the Linux 'nm' command I see the constructor in that library:

    0000000000027c70 t QtDataVisualization::DeclarativeSurface::DeclarativeSurface(QQuickItem*)

    Here is a simple test program

    #include "datavisualizationqml2/declarativesurface_p.h"
    int main(int argc, char **argv) {
      QtDataVisualization::DeclarativeSurface *surface =
        new QtDataVisualization::DeclarativeSurface(nullptr);
      return 0;

    However when I link the test I get "undefined reference" to the DeclarativeSurface constructor:

    g++ -o dvtest -I ~/Qt5.14.2/5.14.2/Src/qtdatavis3d/src -I ~/Qt/5.14.2/Src/qtdatavis3d/include/QtDataVisualization/5.14.2//QtDataVisualization/private/ -I ~/Qt/5.14.2/Src/qtbase/include/ -I ~/Qt/5.14.2/gcc_64/include  -I ~/Qt/5.14.2/gcc_64/include/QtDataVisualization/ -fPIC ~/Qt/5.14.2/gcc_64/qml/QtDataVisualization/ /home/oreilly/Qt/5.14.2/gcc_64/lib/ /home/oreilly/Qt/5.14.2/gcc_64/lib/ /home/oreilly/Qt/5.14.2/gcc_64/lib/ /home/oreilly/Qt/5.14.2/gcc_64/lib/ /home/oreilly/Qt/5.14.2/gcc_64/lib/ /home/oreilly/Qt/5.14.2/gcc_64/lib/ /home/oreilly/Qt/5.14.2/gcc_64/lib/ 
    /tmp/cc5SCIgN.o: In function `main': undefined reference to `QtDataVisualization::DeclarativeSurface::DeclarativeSurface(QQuickItem*)'
    collect2: error: ld returned 1 exit status

    Anyone know why this is?

  • The 'nm' man page indicates that a lower case 't' indicates a function that's "local" to the library - all of the DeclarativeSurface symbols in that library are marked with 't'. How can I find accessible global functions (that I can use) invoke DeclarativeSurface methods?

Log in to reply