Skip to content

Building and developing the TMC plugin for Qt Creator on Windows

nucularmoo edited this page Nov 22, 2017 · 15 revisions

Building and developing the TMC plugin for Qt Creator for Windows.

Setting up your development environment.

Please refer to the instructions for Compiling Qt and Qt Creator on Windows at the Qt Creator GitHub README.

To set up your development environment, you will need to set up the following:

  • Download and install Perl version 5.10 or later
  • Download and install Qt Creator Community Edition from qt.io
    • As a result you will have installed a C++ compiler (MingW) and Qt when installing the CE
  • Download and compile Qt Creator from GitHub (master or latest version)

Please note that we will refer to Qt Creator Community Edition as Qt Creator CE and the Qt Creator you compiled as Qt Creator SA to avoid confusion between the two.

The README instructs you to download and build Qt and MingW separately. This is not required if you download and install the Qt Creator CE. Due to the build time for Qt, we do not recommend downloading and building Qt separately. Please make sure when installing the Qt Creator CE that you also installed Qt and MingW. We have used MingW exclusively as our C++ compiler when working on this project on Windows. The instructions will reflect this choice and if choosing to use Microsoft Visual Studio you are on your own.

The Qt Creator CE IDE will be your development environment IDE. The Qt Creator SA IDE will be your deployment/target IDE.

As instructed in the Qt Creator README, for convenience it is recommended to create a shell prompt with the correct environment variables set for running Qt Creator. We will refer to this file as the qtvars.bat file.

set PATH= <path_to_qt>\bin; <path_to_mingw>\bin; <working_directory>\creator\bin;%PATH%
set QMAKESPEC=win32-g++
set QTC_BUILD= <path_to_Qt_Creator_SA>
set QTC_SOURCE= <path_to_Qt_Creator_SA>
<path_to_Qt_Creator_CE>

Here is an example of what your qtvars.bat file should look like:

set PATH=C:\Qt\5.9.1\mingw53_32\bin;C:\Qt\Tools\mingw530_32\bin;D:\qtcreator\qt-creator\creator\bin;%PATH%
set QMAKESPEC=win32-g++
set QTC_BUILD=D:/qtcreator/qt-creator_SA
set QTC_SOURCE=D:/qtcreator/qt-creator_SA
D:/qtcreator/qt-creator/bin/qtcreator

Building the plugin for Windows

To build the TMC plugin, please open the TMC plugin project in your development environment. Select whether you want to build the "Release" or "Debug" version of the plugin. After building, your .dll file will be located in the plugin directory under your specified QTC_BUILD directory (for example D:/qtcreator/qt-creator_SA/lib/qtcreator/plugins) under the name TestMyCode4.dll if built as "Release" and TestMyCode4d.dll if built as "Debug".

Running the TMC plugin for Qt Creator on Windows using TMC-cli

Prerequisites for running the TMC plugin are:

  1. User has the Java JRE installed and set the environment variables required for running the command java in PowerShell/Command Prompt.
  2. User has the executable tmc-langs-cli .jar file from the tmc-langs repository (for example, tmc-langs-cli-0.7.7-SNAPSHOT.jar or newer) located on their hard drive.
  3. User has the Qt Creator IDE installed/set up deployment/target IDE.

As of writing, local TMC-testing is done using TMC-cli. We are exploring the option of handling the local testing using the Qt Creator plugin autotest instead of TMC-cli in future iterations.

To include TMC-cli, please add the following line to your qtvars.bat file:

set TMC_CLI=<path_to_tmc_cli>/<filename_of_tmc_cli>.jar

Here is an example of what your qtvars.bat file should now look like:

set PATH=C:\Qt\5.9.1\mingw53_32\bin;C:\Qt\Tools\mingw530_32\bin;D:\qtcreator\qt-creator\creator\bin;%PATH%
set QMAKESPEC=win32-g++
set QTC_BUILD=D:/qtcreator/qt-creator_SA
set QTC_SOURCE=D:/qtcreator/qt-creator_SA
set TMC_CLI=D:/tmc-langs-cli-0.7.7-SNAPSHOT.jar
D:/qtcreator/qt-creator/bin/qtcreator

As of writing, deployment/target environment has starting issues. To run the plugin, please copy the TestMyCode4.dll from your deployment/target environment plugin folder and paste it into your development environment plugin folder. Restart your development environment IDE which will now be running using the TMC plugin.