简体   繁体   中英

linking Qt Creator plugin editor / highlighter

I'm working on a qt creator plugin that adds support for certain types of files by supplying customized editors, etc. Right now it registers a new IEditorFactory which produces editors that I based off of the TextEditor::BaseTextEditor and TextEditor::BaseTextEditorWidget.

Eventually I will be creating and using specialized highlighters and other things, but for now I want to utilize things from other qt creator plugins, and this is where I run into trouble.

In particular I want to use the TextEditor::Internal::Highlighter, which can load and utilize kate files. I'm already using other classes from the TextEditor plugin so I have

include($$QTCREATOR_SOURCES/src/plugins/texteditor/texteditor.pri)

added to my project file. Inside texteditor.pri everything seems good

include(texteditor_dependencies.pri)
LIBS *= -l$$qtLibraryName(TextEditor)

and, indeed, I'm able to compile my editor (which is dependent on things inside the texteditor plugin).

The only difference with the TextEditor::Internal::Highlighter -as far as I can tell- is that it's in a subfolder of the texteditor plugin. This should be fine, and the object files seem to all land in the same directory, but when I say

new TextEditor::Internal::Highlighter()

(just as is done in texteditor/plaintexteditor.cpp) I get a linker error

Undefined symbols for architecture x86_64:
  "TextEditor::Internal::Highlighter::Highlighter(QTextDocument*)", referenced from:
      MyPlugin::MyEditorWidget::MyEditorWidget(QWidget*)in myeditor.o
      MyPlugin::MyEditorWidget::MyEditorWidget(QWidget*)in myeditor.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

What am I doing wrong? Are there more dependencies I have to declare? Is there a command I can use to force a folder of object files to be in my path while compiling?

Thnaks!

The classes and methods in the "Internal" namespace tend to not be exported, so they are not available outside the plugin that provides them. Check the class definition: Does it have "SOMETHING_EXPORT" between the class keyword and the class name? If not, then you are out of luck.

By default as few symbols as possible are exported: That leaves us a chance to actually change things around without worrying about breaking code outside the plugin. It also reduces load times a bit. If you have a use-case for the symbol to be exported: Feel free to ask on the Qt Creator mailing list or -- better yet -- provide a patch to codereview.qt-project.org which moves the class out of the Internal namespace and exports the symbol.

A better place to get questions like this answered is the Qt Creator mailing list and the #qt-creator IRC channel on freenode network.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM