Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to solve this error -> undefined reference to `__imp__ZN13QSvgGeneratorC1Ev'



  • I am trying to get Class Diagrams in svg format. I have created headers and included them correctly. However, at run-time this error comes. How to solve this. Help my c++ gurus.



  • @FaraN said in How to solve this error -> undefined reference to `__imp__ZN13QSvgGeneratorC1Ev':
    Hi and welcome.

    I am trying to get Class Diagrams in svg format.

    What does this mean? Something in a program of your own, something in Qt Creator, something else?

    However, at run-time this error comes

    So you are saying this this comes up at run-time (when you run your application), not at link time (during the build)?



  • Yes in Qt Creator, when i press RUN, after building error comes.
    ->
    187ac277-0567-43c1-922e-b6b835d72333-image.png



  • this is the code:

    //Save file as SVG
    
    QString path = QFileDialog::getSaveFileName(w,("Save as image"), "/demo.svg", ("SVG file (*.svg)"));
    
    if (path.isEmpty())
        return;
    temp_img.setFileName(path);
    
    //temp_img.setViewBox(QRect(0, 0, 1000, 1000));
    
    temp_img.setSize(QSize(2000, 2000));


  • @FaraN
    So I don't think this is "after building", I think this is during building at the link stage. Try just doing a build in Creator, not a run, and verify you get this error.

    It looks like you are missing a library for this "SVG Generator", or possibly have not specified it correctly, or it's the wrong version/compiler, or other possibilities.

    You need to state things like: what version of Qt, what platform, what compiler, where this SvgGenerator stuff is supposed to come from (is it the QSvgGenerator Class?), whether you build Qt yourself or got it from somewhere? And most important show your project's .pro file so we can see how you are trying to link?

    If you are indeed using the QSvgGenerator Class, what did you do about the qmake: QT += svg from the doc page?



  • QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    CONFIG += c++11

    You can make your code fail to compile if it uses deprecated APIs.

    In order to do so, uncomment the following line.

    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

    SOURCES +=
    ../Source/array.cpp
    ../Source/button.cpp
    ../Source/class.cpp
    ../Source/constructor.cpp
    ../Source/container.cpp
    ../Source/function.cpp
    ../Source/functions.cpp
    ../Source/globals.cpp
    ../Source/variable.cpp
    ../Source/win_main.cpp
    main.cpp

    HEADERS +=
    ../Headers/array.h
    ../Headers/button.h
    ../Headers/class.h
    ../Headers/constructor.h
    ../Headers/container.h
    ../Headers/function.h
    ../Headers/functions.h
    ../Headers/globals.h
    ../Headers/variable.h
    ../Headers/win_main.h

    FORMS +=

    Default rules for deployment.

    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target



  • @FaraN
    Well you showed your .pro but didn't answer any of the other questions.....

    Anyway, your error message implies to me you are using that QSvgGenerator Class, from whatever route, and I said:

    If you are indeed using the QSvgGenerator Class, what did you do about the qmake: QT += svg from the doc page?

    So try changing to first line to

    QT += core gui svg
    

    Clear out build output directory and try re-running qmake and rebuilding from scratch. Does that help?



  • Respected Sir, I'm doing it. I'll tell you in 10-15 min.
    sorry I can only msg once in 10 minutes. Qt forum is restricting me.



  • Brother, I love you. Bundle of thanks. It worked. 100%

    please provide your linkedin. <3



  • @FaraN
    I appreciate your love, but will accept it anonymously/from a distance. ;-)



  • @JonB thanks again. <3


Log in to reply