2

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
M.Duchemin
  • 63
  • 6

1 Answers1

1

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.
hyde
  • 60,639
  • 21
  • 115
  • 176
  • mmm, okay, I understand how work -L attribut but when I add '-lqscintilla2' like the tutorial I get another error : 'connot find -lqscintilla2' – M.Duchemin Nov 02 '16 at 20:58
  • Well, then, you need to look at the actual link command and the directories added to it with `-L`. Does that include the directory which contains your `qscintilla2.dll` or `libqscintilla2.so` (depending on OS)? – hyde Nov 02 '16 at 21:03
  • Normally you shouldn't expand/change the question after someone has answered (because that invalidates the answer), but in this case, feel free to go ahead and edit the question to update the *.pro* file with this fix, and then include the actual link command, which gives the error (the only current answer is mine, and I won't mind in this case). – hyde Nov 02 '16 at 21:05
  • okay, as you can see i'm new haha, thanks for advice, i edited the question. So, i don't have any `qscintilla2.dll` or `libqscintilla2.so` in the directory. oh and for more precision, i'm on linux (fedora 24) – M.Duchemin Nov 02 '16 at 21:19
  • @M.Duchemin Did you perhaps forget to build QScintilla library, then? :) – hyde Nov 03 '16 at 10:25
  • oh god, yes I miss it XD that work now, thank you again for your help ;) – M.Duchemin Nov 03 '16 at 13:11
  • @M.Duchemin No problem. Btw, the usual way to say "thank you" here is to upvote the post (up-arrowhead at upper left of each post), which made you want to say "thanks" :) – hyde Nov 03 '16 at 16:33
  • Yes, of course, it's normal, but I need 15 reputation points to upvote the post haha. So, when I will get this 15 points, I upvote your post ;) – M.Duchemin Nov 03 '16 at 16:44
  • @M.Duchemin I *think* you can always upvote answers to your own questions, same as you can always comment on them. – hyde Nov 03 '16 at 17:55