0

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!

4

1 回答 1

1

“内部”命名空间中的类和方法往往不会被导出,因此它们在提供它们的插件之外不可用。检查类定义:在类关键字和类名之间是否有“SOMETHING_EXPORT”?如果没有,那么你就不走运了。

默认情况下,导出尽可能少的符号:这让我们有机会实际改变事物,而不必担心在插件之外破坏代码。它还可以稍微减少加载时间。如果您有要导出符号的用例:请随时在 Qt Creator 邮件列表中询问,或者 - 更好的是 - 向 codereview.qt-project.org 提供补丁,将类移出 Internal命名空间并导出符号。

Qt Creator 邮件列表和 freenode 网络上的#qt-creator IRC 频道可以更好地回答此类问题。

于 2012-12-16T00:30:23.207 回答