编译自己的QtCreator插件失败

编译自己的QtCreator插件失败,qt,plugins,qt-creator,Qt,Plugins,Qt Creator,我正试图通过以下指南创建我自己的QtCreator插件 所以我克隆了repo并检查了v2.8.1标记的提交(c3ed746c) 然后我复制了我的QtCreator 2.8.1目录,并创建了一个新的QtCreator插件项目 然后在我的项目目录中创建一个名为MyPlugin.json的新文件 如果我尝试编译插件,则会出现以下错误: e:\qtprojects\build-myplugin-desktop\u qt\u 5\u 1\u msvc2012\u 32bit-debug\debug../.

我正试图通过以下指南创建我自己的QtCreator插件

所以我克隆了repo并检查了v2.8.1标记的提交(c3ed746c)

然后我复制了我的QtCreator 2.8.1目录,并创建了一个新的QtCreator插件项目

然后在我的项目目录中创建一个名为MyPlugin.json的新文件

如果我尝试编译插件,则会出现以下错误:

e:\qtprojects\build-myplugin-desktop\u qt\u 5\u 1\u msvc2012\u 32bit-debug\debug.././myplugin/mypluginplugin.h(6):致命错误C1083:无法打开包含文件:“extensionsystem/iplugin.h”:没有这样的文件或目录 jom:E:\QtProjects\build-MyPlugin-Desktop\u Qt\u 5\u 1\u MSVC2012\u 32bit-Debug\Makefile.Debug[Debug\moc\u mypluginplugin.obj]错误2 jom:E:\QtProjects\build-MyPlugin-Desktop\u Qt\u 5\u 1\u MSVC2012\u 32bit-Debug\Makefile[Debug]错误2 10:56:51:进程“E:\Qt\Qt5\Tools\QtCreator\bin\jom.exe”已退出,代码为2。 生成/部署项目myplugin时出错(工具包:桌面Qt 5.1.1 MSVC2012 32位) 执行步骤“Make”时 10:56:51:运行时间:00:01

我该怎么做才能让它工作

以下是源文件:

myplugin.pro mypluginplugin.h
如果您是linux用户,可以下载
qtcreator dev
。但是,我不知道它在Windows上是如何工作的

  • 开放式终端
  • 类型:
    sudo-apt-get-install-qtcreator-dev
  • 完成了

  • +1简单又好。。。但在其他发行版上该怎么办呢?(Debian没有软件包qtcreator-dev。我需要添加一些apt存储库吗?)。那就好了。通过阅读以下指南,您可以手动添加Ubuntu SDK团队的PPA(
    PPA:Ubuntu SDK团队/PPA
    )。如果不是,我怀疑,我不能提供答案。干杯。
    dev
    版本imho只是在调试模式下构建的Qt创建者。因此,如果(像我一样)有人从源代码处编译QtCreator,他/她还应该在IDE发布版本的同时进行调试。
    DEFINES += MYPLUGIN_LIBRARY
    
     # MyPlugin files
    
    SOURCES += mypluginplugin.cpp
    
    HEADERS += mypluginplugin.h \
            myplugin_global.h \
            mypluginconstants.h
    
     # Qt Creator linking
    
     ## set the QTC_SOURCE environment variable to override the setting here
    QTCREATOR_SOURCES = $$(QTC_SOURCE)
    isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=E:/QtProjects/_QtCreatorPlugIns/qt-creator
    
     ## set the QTC_BUILD environment variable to override the setting here
    IDE_BUILD_TREE = $$(QTC_BUILD)
    isEmpty(IDE_BUILD_TREE):IDE_BUILD_TREE=E:/QtProjects/_QtCreatorPlugIns/QtCreator
    
     ## uncomment to build plugin into user config directory
     ## <localappdata>/plugins/<ideversion>
     ##    where <localappdata> is e.g.
     ##    "%LOCALAPPDATA%\QtProject\qtcreator" on Windows Vista and later
     ##    "$XDG_DATA_HOME/data/QtProject/qtcreator" or "~/.local/share/data/QtProject/qtcreator" on Linux
     ##    "~/Library/Application Support/QtProject/Qt Creator" on Mac
     # USE_USER_DESTDIR = yes
    
    PROVIDER = MyCompany
    
    include($$QTCREATOR_SOURCES/src/qtcreatorplugin.pri)
    
    #ifndef MYPLUGIN_GLOBAL_H
    #define MYPLUGIN_GLOBAL_H
    
    #include <QtGlobal>
    
    #if defined(MYPLUGIN_LIBRARY)
    #  define MYPLUGINSHARED_EXPORT Q_DECL_EXPORT
    #else
    #  define MYPLUGINSHARED_EXPORT Q_DECL_IMPORT
    #endif
    
    #endif // MYPLUGIN_GLOBAL_H
    
    #ifndef MYPLUGINCONSTANTS_H
    #define MYPLUGINCONSTANTS_H
    
    namespace MyPlugin {
        namespace Constants {
    
            const char ACTION_ID[] = "MyPlugin.Action";
            const char MENU_ID[] = "MyPlugin.Menu";
    
        } // namespace MyPlugin
    } // namespace Constants
    
    #endif // MYPLUGINCONSTANTS_H
    
    #ifndef MYPLUGIN_H
    #define MYPLUGIN_H
    
    #include "myplugin_global.h"
    
    #include <extensionsystem/iplugin.h>
    
    namespace MyPlugin {
        namespace Internal {
    
            class MyPluginPlugin : public ExtensionSystem::IPlugin
            {
                    Q_OBJECT
                    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "MyPlugin.json")
    
                public:
                    MyPluginPlugin();
                    ~MyPluginPlugin();
    
                    bool initialize(const QStringList &arguments, QString *errorString);
                    void extensionsInitialized();
                    ShutdownFlag aboutToShutdown();
    
                private slots:
                    void triggerAction();
            };
    
        } // namespace Internal
    } // namespace MyPlugin
    
    #endif // MYPLUGIN_H
    
    #include "mypluginplugin.h"
    #include "mypluginconstants.h"
    
    #include <coreplugin/icore.h>
    #include <coreplugin/icontext.h>
    #include <coreplugin/actionmanager/actionmanager.h>
    #include <coreplugin/actionmanager/command.h>
    #include <coreplugin/actionmanager/actioncontainer.h>
    #include <coreplugin/coreconstants.h>
    
    #include <QAction>
    #include <QMessageBox>
    #include <QMainWindow>
    #include <QMenu>
    
    #include <QtPlugin>
    
    using namespace MyPlugin::Internal;
    
    MyPluginPlugin::MyPluginPlugin()
    {
        // Create your members
    }
    
    MyPluginPlugin::~MyPluginPlugin()
    {
        // Unregister objects from the plugin manager's object pool
        // Delete members
    }
    
    bool MyPluginPlugin::initialize(const QStringList &arguments, QString *errorString)
    {
        // Register objects in the plugin manager's object pool
        // Load settings
        // Add actions to menus
        // Connect to other plugins' signals
        // In the initialize method, a plugin can be sure that the plugins it
        // depends on have initialized their members.
    
        Q_UNUSED(arguments)
        Q_UNUSED(errorString)
    
        QAction *action = new QAction(tr("MyPlugin action"), this);
        Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID,
                                                                 Core::Context(Core::Constants::C_GLOBAL));
        cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A")));
        connect(action, SIGNAL(triggered()), this, SLOT(triggerAction()));
    
        Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID);
        menu->menu()->setTitle(tr("MyPlugin"));
        menu->addAction(cmd);
        Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
    
        return true;
    }
    
    void MyPluginPlugin::extensionsInitialized()
    {
        // Retrieve objects from the plugin manager's object pool
        // In the extensionsInitialized method, a plugin can be sure that all
        // plugins that depend on it are completely initialized.
    }
    
    ExtensionSystem::IPlugin::ShutdownFlag MyPluginPlugin::aboutToShutdown()
    {
        // Save settings
        // Disconnect from signals that are not needed during shutdown
        // Hide UI (if you add UI that is not in the main window directly)
        return SynchronousShutdown;
    }
    
    void MyPluginPlugin::triggerAction()
    {
        QMessageBox::information(Core::ICore::mainWindow(),
                                 tr("Action triggered"),
                                 tr("This is an action from MyPlugin."));
    }
    
    Q_EXPORT_PLUGIN2(MyPlugin, MyPluginPlugin)
    
    E:\QtProjects\_QtCreatorPlugIns> tree
    
    ├───qt-creator
    │   ├───bin
    │   ├───dist
    │   ├───doc
    │   ├───lib
    │   ├───qbs
    │   ├───scripts
    │   ├───share
    │   ├───srcn64interrupt
    │   └───testsster
    ├───QtCreator
    │   ├───bin
    │   ├───lib0
    │   └───share