Search code examples
c++qtqmakeqscintilla

Add Qscintilla library to Qt Problems


i'm trying to add Qscintilla with this tutorial to my Qt Project. The library is successfully installed but there is lot of undefined references on class (undefined reference to 'QsciScintilla::QsciScintilla(QWidget*)' or undefined reference to 'QsciScintilla::SetFont(QFont const&)' for example)

this is my .pro file :

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = QscintillaTest
TEMPLATE = app


SOURCES += main.cpp\
    mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/./QScintilla/Qt4Qt5/release/ -lqscintilla2
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/./QScintilla/Qt4Qt5/debug/ -lqscintilla2
else:unix: LIBS += -L$$PWD/./QScintilla/Qt4Qt5/ -lqscintilla2
INCLUDEPATH += $$PWD/./QScintilla/Qt4Qt5/
DEPENDPATH += $$PWD/./QScintilla/Qt4Qt5/

I hope someone will help me.

EDIT : After adding -lqscintilla2 I get this error :

Cannot find -lqscintilla2

Solution

  • Your .pro file is missing this:

    LIBS += -lqscintilla2
    

    This is mentioned also in the tutorial you linked to...

    The -L you now have only adds directories to library search path, but it alone does not cause any new libraries to be added. You basically never have just the -L alone, because it doesn't really do anything alone (in a normal toolchain setup). The -l switch is used to tell the actual library to add to linking, and then linker searches the library paths it has. So if you have library in its own directory, you need both switches.


    After edit: Then if the actual library file is missing, you should make sure that

    • You have actually built it.
    • You have built the right debug/release version, or probably both.
    • The built library is in the expected directory, matching what you have in the application .pro file.