Important: Please read the Qt Code of Conduct -

Using qscintilla2_qt5 suddenly occurs undefined reference.

  • using Qt-creator of Qt 5.12 On Linux, The qscintilla2 library is from the Linux repo.

    The error occurs when

    1. I installed Qt 5.13, trying to use a different Qt version, but build fail with undefined reference to Qscintilla::xxxx.
    2. I change back to Qt 5.12 and also different Qt-creator in the pack, build fail.
    3. I ensure that the source code is clean with the help of git, the build directory is deleted, the QScintilla2 lib & dev is reinstalled. build fail still. It doesn't make sense. I even tried reboot.
    4. I check the Internet, add one line in the .pro file: LIB + -lqscintilla2_qt5 , it worked. build success.

    But It's said that QMAKE_LFLAGS += -lqscintilla2_qt5 is the same as LIBS += -lqscintilla2_qt5 , with the former line, build fail, with the latter line, build success. Why?

  • Lifetime Qt Champion

    @Gerald-L said in Using qscintilla2_qt5 suddenly occurs undefined reference.:

    But It's said that QMAKE_LFLAGS += -lqscintilla2_qt5 is the same as LIB + -lqscintilla2_qt5

    Where? is the correct way to link libraries with qmake

  • @jsulm It seems that I did it wrong for a long time. It's weird that it didn't build fail before.

  • @jsulm So the general way to use lib is :

    1. use INCLUDEPATH += to specify the path of library header filess.(which can be installed by apt-get install libxxx-dev on Linux)
    2. use LIBS += to specify the binary lib file.

    But, when I use boost on Linux( which is installed from Linux repo, not manually), I didn't add any line in .pro file, just use #include <boost/xxx> in source file, it build ok and works fine, just like the way I use std.
    Is there any system paths that qmake automaticaly checks when it makes the build, and on these occassions we don't need to add the lib and lib headers manually ? Or, even it builds OK, it's not the recommend way, just build ok by accident?

  • Lifetime Qt Champion

    @Gerald-L Part of Boost is header only (without library files), for these parts you do not have to add anything to LIBS. Also there are system wide directories containing header files and libraries which you do not have to specify (/usr/include, /usr/lib).

Log in to reply