Developing Environment

(Prior version for BPS 2.24.0.0 with VS2017 and Qt 5.14.2 here)

To set up the developing environment you should have prepared a developing VM or PC as documented in VM Setup for Development.

The Qt 5.15 toolset described here is used for BPS 2.24.0.1 and up.

The setup is somewhat tricky because it must support 32 and 64 bit development side by side. By following this guide step-by-step it should be possible to master the set up without problems, but it is essential to follow the order as given.

Note that during the setup not all applications will work because the matching DLL's will not yet be found. The required links and settings will get applied in the step Automate Proper DLL Loading, please wait until then.

Perl

Homepage: http://strawberryperl.com/

  • Download 64 bit edition
  • Run strawberry-perl-5.30.1.1-64bit.msi
  • Install to: C:\dev\perl

Python

  • Get binaries from: http://www.python.org
  • Download «Windows x86-64 executable installer»
  • Run python-3.8.0-amd64.exe
  • Uncheck:
    • Install launcher for all users
    • Add Python 3.8 to PATH
  • Customize installation
  • Optional Features
    • Uncheck all
  • Advanced Options
    • Uncheck all
  • Customize install location: C:\dev\python

Clang

  • Unzip libclang-release_100-based-windows-vs2019_32.7z to C:\dev
  • Rename C:\dev\libclang to C:\dev\clang32
  • Unzip libclang-release_100-based-windows-vs2019_64.7z to C:\dev
  • Rename C:\dev\libclang to C:\dev\clang64

Visual Studio 2019

  • Get Visual Studio Community 2019
  • Install «Desktop development with C++»
    • Install optional components:
      • MSVC v142 - VS 2019 C++ x64/x86 build tools
      • Just-In-Time debugger
      • C++ CMake tools for Windows
      • C++ ATL for latest v142 build tools (x86 & x64)
  • Start IDE to check.
  • Exit IDE.

Add Proper SDK

The Windows SDK's offered in the initial setup do not include the latest, so we install it afterwards:

  • Start «Visual Studio Installer» from the Windows Startmenu
  • «Visual Studio Community 2019»
    • Modify
      • Individual components
      • Scroll down to near end of list
      • Check «Windows 10 SDK (10.0.19041-0)
      • Modify

PostgreSQL

Homepage: http://www.postgresql.org/

Download the EDB installers for 32 bit and 64 bit (32 bit only available up to version 10).

  • Run postgresql-12.3-1-windows-x64.exe
    • Installation Directory: C:\dev\pgsql64
    • Unckeck all but «Command Line Tools»
  • Run postgresql-10.13-1-windows.exe
    • Installation Directory: C:\dev\pgsql32
    • Unckeck all but «Command Line Tools»

Unfortunately the include folder is missing from above installation. So download the matching binaries in zip files as well, then:

  • postgresql-12.3-1-windows-x64-binaries.zip
    • 7-Zip
      • Extract files…
      • to: C:\dev\
  • Copy folder C:\dev\pgsql\include to C:\dev\pgsql64
  • Delete C:\dev\pgsql
  • postgresql-10.13-1-windows-binaries.zip
    • 7-Zip
      • Extract files…
      • to: C:\dev\
  • Copy folder C:\dev\pgsql\include to C:\dev\pgsql32
  • Delete C:\dev\pgsql

PgAdmin

Oracle Instant Client

Slim client software and sdk for Oracle.

Homepage: http://www.oracle.com/technetwork/database/features/instant-client/index.html

  • Right click on instantclient-basiclite-windows.x64-19.5.0.0.0dbru.zip
    • 7-Zip
      • Extract files…
      • to: C:\dev\oracle64
  • Repeat for:
    • instantclient-sdk-windows.x64-19.5.0.0.0dbru.zip
    • Optional: instantclient-sqlplus-windows.x64-19.5.0.0.0dbru.zip
    • Optional: instantclient-tools-windows.x64-19.5.0.0.0dbru.zip
  • Rename:
    • C:\dev\oracle64\instantclient_19_5 to C:\dev\oracle64\instantclient
  • Right click on instantclient-basiclite-nt-19.5.0.0.0dbru.zip
    • 7-Zip
      • Extract files…
      • to: C:\dev\oracle32
  • Repeat for:
    • instantclient-sdk-nt-19.5.0.0.0dbru.zip
    • Optional: instantclient-sqlplus-nt-19.5.0.0.0dbru.zip
    • Optional: instantclient-tools-nt-19.5.0.0.0dbru.zip
  • Rename:
    • C:\dev\oracle32\instantclient_19_5 to C:\dev\oracle32\instantclient
  • Create C:\dev\oracle64\tnsnames.ora.
    Example:
    VMORA18 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = vmora18)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = xepdb1)
        )
      )
     
    VMORA19 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = vmora19)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = pdb1)
        )
      )
  • Add to the begin of the system variable PATH: C:\dev\oracle64\instantclient\
  • Add new system environment variable: TNS_ADMIN=C:\dev\oracle64

Oracle SQL Developer

Homepage: http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html

  • Download the latest Windows 64-bit zip file including JDK
  • Right click on sqldeveloper-19.2.1.247.2212-x64.zip
    • 7-Zip
      • Extract files…
      • to: C:\dev
  • Do not yet run sqldeveloper, wait til after Automate proper DLL loading

For high DPI displays:

  • Uncheck «Show on startup» at bottom of the start page.
  • If you want to see it again: Help - Start Page

Jom

Replacement for nmake, compiles on multiple CPU cores simultaneously.

Homepage: http://wiki.qt.io/Jom

Download latest binary release.

  • Right click on jom_1_1_3.zip
    • 7-Zip
      • Extract files…
      • to: C:\dev\jom

NASM

Net-wide Assembler. Required for OpenSSL build.

Homepage: http://www.nasm.us/

  • Right click on nasm-2.14.02-win64.zip
    • 7-Zip
      • Extract files…
      • to: C:\dev
  • Rename C:\dev\nasm-2.14.02 to C:\dev\nasm

OpenSSL

Homepage: http://www.openssl.org/

  • Download latest source tarball

Prepare source:

  • Right click on openssl-1.1.1g.tar.gz
    • 7-Zip
      • Extract here
  • Right click on openssl-1.1.1g.tar
    • 7-Zip
      • Extract files…
      • to: C:\dev
  • Rename C:\dev\openssl-1.1.1g to C:\dev\openssl

Create 32-bit:

  • Start / Visual Studio 2019 / x86 Native Command Prompt AS ADMINISTRATOR
  • cd \dev\openssl
  • PATH=C:\dev\nasm;C:\dev\perl\perl\bin;%PATH%
  • perl Configure VC-WIN32 --prefix=c:\dev\openssl32 --openssldir=c:\dev\openssl32
  • nmake
  • nmake test
  • nmake install
  • nmake clean
  • exit

Build 64 bit:

  • Start / Visual Studio 2019 / x64 Native Command Prompt AS ADMINISTRATOR
  • cd \dev\openssl
  • PATH=C:\dev\nasm;C:\dev\perl\perl\bin;%PATH%
  • perl Configure VC-WIN64A --prefix=c:\dev\openssl64 --openssldir=c:\dev\openssl64
  • nmake
  • nmake test
  • nmake install
  • nmake clean
  • exit

Prepare Qt

Get source:

Apply patches:

  • C:\dev\qt\qtbase\src\widgets\itemviews\qlistwidget.h
    C:\dev\qt\qtbase\src\widgets\widgets\qcombobox.h
    • Move “addItems” to “public Q_SLOTS”
  • C:\dev\qt\qtbase\src\corelib\kernel\qvariant.h
    • Insert at end of file, immediately before QT_END_NAMESPACE:
      Q_CORE_EXPORT const QVariant::Handler* userVariantHandler();
      Q_CORE_EXPORT void setUserVariantHandler(const QVariant::Handler* aHandler);
  • C:\dev\qt\qtbase\src\corelib\kernel\qvariant.cpp
    • Insert after function QVariantPrivate::registerHandler (approx. line 1591):
      Q_CORE_EXPORT const QVariant::Handler* userVariantHandler()
      {
      	return handlerManager[QMetaType::User];
      }
       
      Q_CORE_EXPORT void setUserVariantHandler(const QVariant::Handler* aHandler)
      {
      	handlerManager.registerHandler(QModulesPrivate::Unknown, aHandler);
      }
  • C:\dev\qt\qtbase\src\network\socket\qlocalsocket_win.cpp
    • Change statement in line 144:
          if (d->serverName.startsWith(QLatin1String("\\\\")/*pipePath*/))
  • C:\dev\qt\qtbase\src\printsupport\kernel\qprintengine_win.cpp
    • In function QWin32PrintEnginePrivate::setPageSize(const QPageSize &pageSize) starting approx. at line 1620
    • Replace: printerPageSize.isValid()
      by: pageSize.id()!=QPageSize::Custom && printerPageSize.isValid()
    • In line 1629 approximately:
          const QPageSize usePageSize = pageSize.id()!=QPageSize::Custom && printerPageSize.isValid() ? printerPageSize : pageSize;
    • In line 1635 approximately:
          if (pageSize.id()!=QPageSize::Custom && printerPageSize.isValid()) {

Qt Build Command Prompts

Create C:\dev\bat\qtbuildenv.bat:

@echo off
if "%1" == "32" goto setenv32
    call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
    PATH=C:\dev\clang64\bin;C:\dev\qt64\qtbase\bin;%PATH%
    set INCLUDE=C:\dev\openssl64\include;%INCLUDE%
    set LIB=C:\dev\openssl64\lib;%LIB%
    set LLVM_INSTALL_DIR=C:\dev\clang64
    goto setenv
:setenv32
    call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
    PATH==C:\dev\clang32\bin;C:\dev\qt32\qtbase\bin;%PATH%
    set INCLUDE=C:\dev\openssl32\include;%INCLUDE%
    set LIB=C:\dev\openssl32\lib;%LIB%
    set LLVM_INSTALL_DIR=C:\dev\clang32
:setenv
    PATH=C:\dev\python;%PATH%
    PATH=C:\dev\perl\bin;%PATH%
    PATH=C:\dev\nasm;%PATH%
    PATH=C:\dev\jom;%PATH%
    PATH=C:\dev\qt\qtbase\bin;%PATH%
    PATH=C:\dev\qt\gnuwin32\bin;%PATH%
cd /d C:\dev

Create the shortcut Qt32 Command Prompt:

  • Target: %COMSPEC% /k qtbuildenv.bat 32
  • Execute in: C:\dev\bat

Create the shortcut Qt64 Command Prompt:

  • Target: %COMSPEC% /k qtbuildenv.bat 64
  • Execute in: C:\dev\bat

Build Qt

Run Qt64 Command Prompt:

  • mkdir \dev\qt64
  • cd \dev\qt64
  • ..\qt\configure -prefix C:\dev\qt64\qtbase -nomake examples -nomake tests -skip qtwebengine -opensource -confirm-license
  • jom
  • jom docs

Run Qt32 Command Prompt:

  • mkdir \dev\qt32
  • cd \dev\qt32
  • ..\qt\configure -prefix C:\dev\qt32\qtbase -nomake examples -nomake tests -skip qtwebengine -opensource -confirm-license
  • jom
  • Do not build docs for qt32, those in qt64 are sufficient

Get and Prepare Qt Solutions

    • Click Clone or download
    • Download ZIP
  • Create folder C:\dev\qtsol64
  • Extract directories C:\dev\qtsol64:
    • qtpropertybrowser
    • qtservice
    • qtsingleapplication

Patches:

  • C:\dev\qtsol64\qtpropertybrowser\common.pri:
    QTPROPERTYBROWSER_LIBNAME = $$qtLibraryTarget(QtSolutions_PropertyBrowser-head)
    QTPROPERTYBROWSER_LIBNAME = $$qtLibraryTarget(QtPropertyBrowser)
  • C:\dev\qtsol64\qtservice\common.pri:
    QTSERVICE_LIBNAME = QtSolutions_Service-head
    QTSERVICE_LIBNAME = QtService
  • C:\dev\qtsol64\qtsingleapplication\common.pri:
    QTSINGLEAPPLICATION_LIBNAME = $$qtLibraryTarget(QtSolutions_SingleApplication-head)
    QTSINGLEAPPLICATION_LIBNAME = $$qtLibraryTarget(QtSingleApplication)
  • C:\dev\qtsol64\qtsingleapplication\src\qtsingleapplication.cpp:
    • Append to header includes:
      #if defined(Q_OS_WIN)
          #include <windows.h>
      #endif
    • Insert to sysInit(…):
      #if defined(Q_OS_WIN)
          AllowSetForegroundWindow(ASFW_ANY);
      #endif
  • C:\dev\qtsol64\qtsingleapplication\buildlib\buildlib.pro:
    • Append:
      win32: LIBS += -lUser32
  • Copy: C:\dev\qtsol64 to C:\dev\qtsol32

Build Qt Solutions

Run Qt64 Command Prompt:

  • cd \dev\qtsol64\qtpropertybrowser
    • configure -library
    • qmake
    • jom debug
    • jom release
    • cd doc\html
    • qhelpgenerator qtpropertybrowser.qhp
  • cd \dev\qtsol64\qtservice
    • configure -library
    • qmake
    • jom debug
    • jom release
    • cd doc\html
    • qhelpgenerator qtservice.qhp
  • cd \dev\qtsol64\qtsingleapplication
    • configure -library
    • qmake
    • jom debug
    • jom release
    • cd doc\html
    • qhelpgenerator qtsingleapplication.qhp

Run Qt32 Command Prompt:

  • cd \dev\qtsol32\qtpropertybrowser
    • configure -library
    • qmake
    • jom debug
    • jom release
  • cd \dev\qtsol32\qtservice
    • configure -library
    • qmake
    • jom debug
    • jom release
  • cd \dev\qtsol32\qtsingleapplication
    • configure -library
    • qmake
    • jom debug
    • jom release

Automate proper DLL loading

Create C:\dev\bat\makelinks.bat:

@echo off 
setlocal
rem Check or get admin privileges
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    exit /b
:gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )

rem Create links
call :makelink dev.openssl C:\dev\openssl32\bin C:\dev\openssl64\bin64
call :makelink dev.clang C:\dev\clang32\bin C:\dev\clang64\bin
call :makelink dev.qt C:\dev\qt32\qtbase\bin C:\dev\qt64\qtbase\bin
call :makelink dev.plugins C:\dev\qt32\qtbase\plugins C:\dev\qt64\qtbase\plugins
call :makelink dev.oracle C:\dev\oracle32\instantclient C:\dev\oracle64\instantclient
call :makelink dev.pgsql.bin C:\dev\pgsql32\bin C:\dev\pgsql64\bin
call :makelink dev.pgsql.lib C:\dev\pgsql32\lib C:\dev\pgsql64\lib
call :makelink dev.bps C:\dev\bps\Release32\bin C:\dev\bps\Release64\bin
pause
goto :eof
 
:makelink
if exist %SystemRoot%\SysWOW64\%1 rmdir /q %SystemRoot%\SysWOW64\%1
if exist %SystemRoot%\System32\%1 rmdir /q %SystemRoot%\System32\%1
mklink /d %SystemRoot%\SysWOW64\%1 %2
mklink /d %SystemRoot%\System32\%1 %3
  • Run makelinks.bat to create the links.
  • Add to PATH in system environment variables:
    • C:\Windows\System32\dev.openssl
    • C:\Windows\System32\dev.clang
    • C:\Windows\System32\dev.qt
    • C:\Windows\System32\dev.oracle
    • C:\Windows\System32\dev.pgsql.lib
    • C:\Windows\System32\dev.pgsql.bin
    • C:\Windows\System32\dev.bps
  • Add new system environment variable
    • QT_PLUGIN_PATH=C:\Windows\System32\dev.plugins

From now on the right DLL's and Qt-plugins for 32 or 64 bit applications will be found automatically.

Qt Assistant Usage

Run Qt Assistant in C:\dev\qt64\qtbase\bin:

  • Pin to taskbar
  • Wait for indexing to finish at first run.
  • Edit - Preferences - Documentation - Add…
    • C:\dev\qtsol64\qtpropertybrowser\doc\html\qtpropertybrowser.qch
    • C:\dev\qtsol64\qtservice\doc\html\qtservice.qch
    • C:\dev\qtsol64\qtsingleapplication\doc\html\qtsingleapplication.qch

Qt Creator

Run Qt64 Command Prompt:

  • mkdir c:\dev\qtcre64
  • cd c:\dev\qtcre64
  • c:\dev\qt64\qtbase\bin\qmake.exe -r c:\dev\qtcre
  • jom
  • jom docs

Run C:\dev\qtcre64\bin\qtcreator.exe

Setup

Saving Space

In case you want to save space you can activate compression on selected folders in C:\dev.

We do this without any noticable problems or speed impacts on folders which are more or less static once the system is complete.

This is how to do it:

  • Right click on the folder
    • Properties
      • General
        • Advanced…
          • [x] Compress contents to save disk space
          • OK
        • OK
        • (o) Apply changes to this folder, subfolders and files
        • OK
  • You can switch off compression of the folder or any subfolders again by unchecking the option.

Example

What Next

Proceed from here either to Custom Apps and Plugins if you want to develop your own components, or to Core Development if you want to develop on the BPS core itself.