Skip to content

Instantly share code, notes, and snippets.

@ssweber
Last active January 12, 2025 12:31
Show Gist options
  • Save ssweber/0519e50942926e4a32c22d49b280c0e6 to your computer and use it in GitHub Desktop.
Save ssweber/0519e50942926e4a32c22d49b280c0e6 to your computer and use it in GitHub Desktop.

Table of Contents

  1. Introduction
  2. Prerequisites
  3. Environment Setup
  4. Download KDE Components
  5. Build KDE Components
  6. SQLite Configuration
  7. Build QElectroTech

1. Introduction

This guide provides a comprehensive walkthrough for setting up and building QElectroTech, along with its required KDE components (extra-cmake-modules, kcoreaddons, and kwidgetsaddons) using MinGW on Windows. It covers everything from installing necessary tools and dependencies to downloading source code, configuring the build environment, and compiling the application.

By following this guide, you'll:

  • Set up prerequisites like Qt, Git, and CMake.
  • Download and configure KDE components.
  • Compile QElectroTech and its dependencies.
  • Deploy the application for use on Windows.

For a smooth experience, ensure your antivirus software is temporarily disabled, as it can interfere with the build and linking processes.

2. Prerequisites

Before starting the build process, ensure the following tools and dependencies are installed and properly configured:

2.1 Install Qt

  1. Download the Qt Online Installer.
  2. During installation:
    • Select Custom Installation.
    • See Qt 5 by checking 'Archive' and clicking 'Filter' button
    • Enable Qt 5.15.2MinGW 8.1.0 64-bit under the Archive section.
    • Enable Build ToolsMinGW 8.1.0 64-bit.
  3. After installation:
    • Qt will be installed at: C:\Qt\5.15.2\mingw81_64.
    • MinGW will be available at: C:\Qt\Tools\mingw810_64\bin.

2.2 Install Git

  1. Download and install Git for Windows.
  2. Add Git to your system PATH during installation.
  3. Verify installation:
    git --version

2.3 Install CMake

  1. Download and install CMake.
  2. Add CMake to your system PATH during installation.
  3. Verify installation:
    cmake --version

2.4 Add MinGW to PATH

  1. Add the following directory to your PATH environment variable:
    C:\Qt\Tools\mingw810_64\bin
    
  2. Verify installation:
    mingw32-make --version

3. Environment Setup

To ensure a smooth build process, configure the following environment variables:

3.1 Set the QTPATH Variable

Set the QTPATH environment variable to point to your Qt installation directory. For example:

SET QTPATH=C:\Qt\5.15.2\mingw81_64

⚠️ Tip: Adding these variables temporarily works for the current session. To make them permanent, update your system’s environment variables through the Control Panel or Command Prompt.

4. Download KDE Components

Manually download the required KDE repositories using Git. This process involves cloning specific branches of the repositories into a local directory.

4.1 Create a Base Directory

Decide on a directory where you want to store the KDE components. For example:

cd C:\Path\To\Your\Projects

4.2 Clone the Repositories

Use the following commands to download the necessary components:

Download extra-cmake-modules:

git clone --branch kf5 https://github.com/KDE/extra-cmake-modules kde-components\extra-cmake-modules

Download kcoreaddons:

git clone --branch kf5 https://github.com/KDE/kcoreaddons kde-components\kcoreaddons

Download kwidgetsaddons:

git clone --branch kf5 https://github.com/KDE/kwidgetsaddons kde-components\kwidgetsaddons

After cloning, your directory structure should look like this:

kde-components\
  extra-cmake-modules\
  kcoreaddons\
  kwidgetsaddons\

4.3 Verify the Download

Check that all repositories were successfully downloaded:

dir kde-components

You should see directories for extra-cmake-modules, kcoreaddons, and kwidgetsaddons.


5. Build KDE Components

This section explains how to build each required KDE component (extra-cmake-modules, kcoreaddons, and kwidgetsaddons). These steps involve configuring the build environment, running cmake, and compiling with mingw32-make.


5.1 Build extra-cmake-modules

  1. Navigate to the extra-cmake-modules directory:
    cd kde-components\extra-cmake-modules
  2. Configure and build the component:
    cmake -DCMAKE_INSTALL_PREFIX=%QTPATH% -G "MinGW Makefiles"
    mingw32-make install

5.2 Build kcoreaddons

  1. Navigate to the kcoreaddons directory and create a build folder:
    cd kde-components\kcoreaddons
    mkdir build
    cd build
  2. Configure and build the component:
    cmake .. -DCMAKE_INSTALL_PREFIX=%QTPATH% -DCMAKE_PREFIX_PATH=%QTPATH% -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=OFF -DZLIB_LIBRARY:FILEPATH=C:\Qt\Tools\mingw810_64\x86_64-w64-mingw32\lib\libz.a
    mingw32-make
    mingw32-make install

5.3 Build kwidgetsaddons

  1. Navigate to the kwidgetsaddons directory and create a build folder:
    cd kde-components\kwidgetsaddons
    mkdir build
    cd build
  2. Configure and build the component:
    cmake .. -DCMAKE_INSTALL_PREFIX=%QTPATH% -DCMAKE_PREFIX_PATH=%QTPATH% -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=OFF -DZLIB_LIBRARY:FILEPATH=C:\Qt\Tools\mingw810_64\x86_64-w64-mingw32\lib\libz.a
    mingw32-make
    mingw32-make install

⚠️ Note: Ensure the %QTPATH% environment variable is correctly set before building these components.

6. SQLite Configuration

Follow these steps to download and set up SQLite for use with QElectroTech.


6.1 Download SQLite Files

  1. Download the source and x64 DLL files from the SQLite Download Page.

  2. Extract both archives to the same directory.


6.2 Generate sqlite3.lib

  1. Open a command prompt and navigate to the directory where you extracted the files.
  2. Run the following command to generate the library file:
    dlltool --def sqlite3.def --output-lib sqlite3.lib --dllname sqlite3.dll

6.3 Update qelectrotech.pro

Modify the qelectrotech.pro file to properly link SQLite:

  1. Locate and remove the following line (line 257):

    unix|win32: PKGCONFIG += sqlite3
    
  2. Replace it with:

    unix: PKGCONFIG += sqlite3
    
    win32:LIBS += "C:/Path/To/Sqlite/sqlite3.lib"
    win32:INCLUDEPATH += "C:/Path/To/Sqlite/sqlite"    # Path to sqlite3.h header file
    

⚠️ Note: Ensure the paths in the replacement lines point to the correct location of your SQLite files.

7. Build QElectroTech

The QElectroTech build process requires Git Bash for certain steps. It will not work in Window's cmd.exe. Ensure all prerequisites and dependencies are set up before proceeding.


7.1 Clone the QElectroTech Repository

  1. Open Git Bash.
  2. Clone the QElectroTech source code:
    git clone https://github.com/qelectrotech/qelectrotech-source-mirror.git
  3. Navigate to the repository and initialize submodules:
    cd qelectrotech-source-mirror
    git submodule update --init --recursive

7.2 Configure the Build

  1. Create a build directory inside the repository:
    mkdir build
    cd build
  2. Use the qmake tool from your Qt installation to generate a Makefile:
    /c/Qt/5.15.2/mingw81_64/bin/qmake.exe -o Makefile ../qelectrotech.pro

7.3 Compile the Application

Run the following command in Git Bash to build the project:

mingw32-make -j8

7.4 Deploy QElectroTech

  1. Use windeployqt to prepare the application for execution:

    /c/Qt/5.15.2/mingw81_64/bin/windeployqt.exe ./release/qelectrotech.exe
  2. Place the deployment files in the same directory as the qelectrotech.exe.


7.5 Launch QElectroTech

To properly launch the application:

  1. Download Launch QET.bat.
  2. Place the batch script in the QElectroTech main folder.
  3. Run the batch file to start QElectroTech.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment