On Fri, Mar 08, 2024 at 07:28:08AM +0800, ogre up wrote: > Hi all, > I want to implement a qt creator plug-in that can read specified > variables (such as a vector with more elements) from the debugger, and > then export the variable values to a text file. > Currently, simple sample plug-ins can be compiled and loaded according > to the qt creator wizard (using qt creator 4.12.4/Qt 5.14.2/vs2017 > build tools), but when trying to use the Debugger class, a compilation > error will appear, prompting an unresolved external symbol. I tried > adding a dependency on debugger in the pro file, but it didn't seem to > have any effect. > complier error message as follows: > example.obj : error LNK2019: Unresolved external symbol "public: static > class QPointer<class Debugger::Internal::DebuggerEngine> __cdecl > Debugger::Internal::EngineManager::currentEngine(void)" > (?currentEngine@EngineManager@Internal > @Debugger@@SA?AV?$QPointer@VDebuggerEngine@Internal@Debugger@@@@XZ), > this symbol is in the function "private: void __cdecl > Example::Internal::ExamplePlugin::triggerAction(void)" (?triggerAction@ > Referenced in ExamplePlugin@Internal@Example@@AEAAXXZ) > ..\..\..\..\Qt\qtcreator-4.12.4\lib\qtcreator\plugins\Example4.dll : > fatal error LNK1120: 1 unresolved external command > some of the source code as follows: > void ExamplePlugin::triggerAction() > { > QMessageBox::information(Core::ICore::mainWindow(), > tr("Action Triggered"), > tr("This is an action from Example.")); > Debugger::Internal::DebuggerEngine *engine = > Debugger::Internal::EngineManager::currentEngine(); > if (engine) > { > // try fetch variable by name, and dump it's values to text > file ... > } > } > and lib dependency settings in pro file: > -------------------------------------------- > QTC_PLUGIN_NAME = Example > QTC_LIB_DEPENDS += \ > # nothing here at this time > QTC_PLUGIN_DEPENDS += \ > coreplugin \ > debugger \ > projectexplorer > QTC_PLUGIN_RECOMMENDS += \ > # optional plugin dependencies. nothing here at this time > ----------------------------------------------------------------------- > --- > I would like to know: > 1. How to solve the above compilation error? > 2. To achieve the function I want, what code snippets can I refer to? > Any suggestion would be appreciated.
The '::Internal' in Debugger::Internal:: is the sign that this is not an exported class, i.e. not meant for public consumption or re-use, i.e. you cannot use this from outside the debugger plugin itself. As a non-recommended solution, to make this work, you could add DEBUGGER_EXPORT to Debugger::Internal::EngineManager in a local build of Qt Creator and go from there. However, I think that having a way to export vector data to a file from the debugger (e.g. via a context menu entry in the "Locals" pane) would be a good feature to have in general, so I'd suggest to implement this directly in the regular debugger plugin, either via a patch submitted by you on codereview.qt-project.org (preferred) or as a feature request on bugreports.qt.io. Andre' -- Qt-creator mailing list Qt-creator@qt-project.org https://lists.qt-project.org/listinfo/qt-creator