Creating Simple Plugin for Qt creator



  • Hello all , i want to create a simple/sample plugin for learning. I am following this guide : https://doc-snapshots.qt.io/qtcreator-extending/first-plugin.html

    I have followed till step 6 where one have to provide path to sources and build dir .
    I have provided these :

    sources : "/home/nightmare/Qt5.9.4/5.9.4/Src/"
    build : "/home/nightmare/Qt5.9.4/5.9.4/gcc_64/bin/"

    I have followed the wizard exactly and my project dir is something like this
    project dir : "/home/nightmare/practice/hello_plugin/"
    structure :
    ".
    ├── Example.json.in
    ├── example.pro
    ├── example.pro.user
    ├── example_global.h
    ├── exampleconstants.h
    ├── exampleplugin.cpp
    └── exampleplugin.h

    0 directories, 7 files
    "

    When i click on build and run i get following error ( i have tried build and run in both Debug and release mode )

    Errors :
    /home/nightmare/practice/hello_plugin/exampleplugin.cpp:1: In file included from ../hello_plugin/exampleplugin.cpp:1:0:

    /home/nightmare/practice/hello_plugin/exampleplugin.h:5: error: extensionsystem/iplugin.h: No such file or directory

    what should i do to resolve it ? is my Src and build path correct .

    P.S. i am using Qt "qt-opensource-linux-x64-5.9.4.run" that i downloaded from qt official site .



  • SOLUTION

    with the help of @mrjj i found solution. It's just that instructions were not clear on tutorial

    Steps

    1. get the Qt creator source : git clone --recursive https://code.qt.io/qt-creator/qt-creator.git

    2. set qmake version . your qmake version should be close to the qt version you are using . for e.g. if you are building for 5.10 your qmake should also use 5.10.

    you can set qmake version by

    sudo mv /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf_orig
    
    sudo vim /usr/share/qtchooser/my_Qt_5.10.0_Desktop_gcc_x64.conf
    
    <Qt_dir>/5.10.0/gcc_64/bin
    <Qt_dir>/5.10.0/gcc_64/lib
    
    ln -s /usr/share/qtchooser/my_Qt_5.10.0_Destop_gcc_x64.conf /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf
    
    
    

    check qmake by qmake --version

    mkdir qt-creator-build
    cd qt-creator-build
    qmake ../qt-creator/qtcreator.pro

    
    4.  ```
    cd qt-creator-build
    make qmake_all
    make -j <number-of-cpu-cores+1>
    
    1. wait for some time . it will take long time to build.

    2. now you have both source and build of Qt creator . Now just follow the wizard and point the qt soruce and build locations

    3. build and run

    4. voila !! \0/


  • Lifetime Qt Champion

    Hi
    So it cannot find iplugin.h
    if you go to the file and press F2 on it ( to go to source)
    can it find it ?

    It comes from Creator source code so you might need to get that if you didn't already.

    When you run the wizard to create the plugin. you have to point to the Creator source code.
    Its not included in the normal Qt install.



  • So i downloaded qt-creator source : git clone --recursive https://code.qt.io/qt-creator/qt-creator.git

    then i again followed the wizard and this time pointed to qt-creator source .
    source : "/home/nightmare/sources/qt-creator/"
    build : "/home/nightmare/sources/qt-creator/bin/"

    Now there are different errors.

    Errors :
    :-1: error: cannot find -lCore
    :-1: error: cannot find -lAggregation
    :-1: error: cannot find -lExtensionSystem
    :-1: error: cannot find -lUtils
    :-1: error: collect2: error: ld returned 1 exit status



  • SOLUTION

    with the help of @mrjj i found solution. It's just that instructions were not clear on tutorial

    Steps

    1. get the Qt creator source : git clone --recursive https://code.qt.io/qt-creator/qt-creator.git

    2. set qmake version . your qmake version should be close to the qt version you are using . for e.g. if you are building for 5.10 your qmake should also use 5.10.

    you can set qmake version by

    sudo mv /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf_orig
    
    sudo vim /usr/share/qtchooser/my_Qt_5.10.0_Desktop_gcc_x64.conf
    
    <Qt_dir>/5.10.0/gcc_64/bin
    <Qt_dir>/5.10.0/gcc_64/lib
    
    ln -s /usr/share/qtchooser/my_Qt_5.10.0_Destop_gcc_x64.conf /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf
    
    
    

    check qmake by qmake --version

    mkdir qt-creator-build
    cd qt-creator-build
    qmake ../qt-creator/qtcreator.pro

    
    4.  ```
    cd qt-creator-build
    make qmake_all
    make -j <number-of-cpu-cores+1>
    
    1. wait for some time . it will take long time to build.

    2. now you have both source and build of Qt creator . Now just follow the wizard and point the qt soruce and build locations

    3. build and run

    4. voila !! \0/