Important: Please read the Qt Code of Conduct -

[Solved]Compilation error while using libSBML in project

  • Hello everyone!

    I have build libSBML statically , so there are three files in my lib folder: libsbml.a, libsbml.dll.a and

    My .pro file:

    @INCLUDEPATH += C:/libsbml-5.10.2/libsbml/include
    LIBPATH += C:/libsbml-5.10.2/libsbml/lib
    LIBS += -lsbml@

    When I'm trying to run this code:

    @SBMLDocument* document = readSBML(argv[1]);

    unsigned int errors = document->getNumErrors();
    cout << endl;
    cout << " filename: " << argv[1] << endl;
    cout << " error(s): " << errors << endl;
    cout << endl;
    if (errors > 0) document->printErrors(cerr);@

    so get some errors, like this:

    ./debug\main.o: In function Z5qMainiPPc': C:\Users\Klayman\Desktop\build-3dCube-Desktop_Qt_5_3_MinGW_32bit-Debug/../3dCube/main.cpp:62: undefined reference toreadSBML'
    C:\Users\Klayman\Desktop\build-3dCube-Desktop_Qt_5_3_MinGW_32bit-Debug/../3dCube/main.cpp:64: undefined reference to SBMLDocument::getNumErrors() const' C:\Users\Klayman\Desktop\build-3dCube-Desktop_Qt_5_3_MinGW_32bit-Debug/../3dCube/main.cpp:69: undefined reference toSBMLDocument::printErrors(std::ostream&) const'
    collect2.exe: error: ld returned 1 exit status

    Please let me know if any idea.

  • Lifetime Qt Champion


    Sounds like the library is not found, it should rather be

    LIBS += -LC:/libsbml-5.10.2/libsbml/lib
    LIBS += -lsbml

    Hope it helps

  • Thank you! I found that I built library in wrong way...

Log in to reply