OpenTX 2.3 Windows Build Instructions - stodev-com-br/opentx GitHub Wiki
To build OpenTX 2.3 on Windows using Microsoft Visual Studio and associated tools please follow the steps listed below.
These instructions assume that you are starting from a clean slate, with nothing installed. If you already have one of the build environment tools installed you may need to adapt the instructions accordingly.
https://visualstudio.microsoft.com/downloads/
- Under Workloads select Desktop development with C++
- Download the Qt Online Installer from https://www.qt.io/download-qt-installer
- De-select all components
- Expand the latest version (the top item) and select MSVC 2019 32-bit
- Expand Developer and Designer Tools and select MinGW 8.1.0 32-bit
- Click Next to install the selected tools
When the installation is finished:
- Add these folders to the system PATH:
C:\Qt\Tools\mingw810_32\bin
C:\Qt\Tools\QtCreator\bin
- Copy
C:\Qt\Tools\QtCreator\bin\libclang.dll
to the Windows System folder (C:\Windows\System32)
- Choose the latest Windows x64 or x86 installer as appropriate for your system
- During the installation check the option to Add cmake to the path for all users
https://www.python.org/downloads/windows/
- Install for all users
- Select path in custom installation method
For the following step open a cmd.exe Prompt by using Right click and select Run as administrator
pip install pillow clang pyqt5
This should finish with a listing that pillow, clang, and pyqt5 packages were successfully installed
- You can ignore the warnings listed that pip has an updated version available
ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.exe
- Using 7-Zip or similar open above .exe file and Extract contents to "C:\Programs\pthreads". "C:\Programs" typically needs to be explicitly created and is not to be confused with "C:\Program Files" nor "C:\Program Files (x86)".
Note on compiler version: while this version may look old (and it is), it is the only one guaranteed to work with 2.3.x versions of OpenTX. Using other versions can (and likely will) produce issues ranging from radio not booting to pulses issues.
http://www.libsdl.org/release/SDL-devel-1.2.15-VC.zip
- Unzip SDL-devel-1.2.15-VC.zip to "C:\Programs\SDL"
https://github.com/opentx/opentx
For the following steps open a Command Prompt (cmd.exe)
SET PATH=%PATH%;C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\bin
SET C_INCLUDE_PATH=C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include
SET CPLUS_INCLUDE_PATH=C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include\c++\4.7.4;C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include\c++\4.7.4\arm-none-eabi
- cmake is used to configure the build.
cmake -G "MinGW Makefiles" -S [path to source] -B [path to build folder] -DCMAKE_PREFIX_PATH=[path to Qt MSVC2019 folder] -DDISABLE_COMPANION=YES [build options]
For example, to configure the firmware build for the RadioMaster TX16S:
cmake -G "MinGW Makefiles" -S C:\Temp\opentx -B C:\Temp\OpenTX-Firmware -DCMAKE_PREFIX_PATH=C:\qt\5.15.2\msvc2019 -DDISABLE_COMPANION=YES -DPCB=X10 -DPCBREV=TX16S -DINTERNAL_MODULE_MULTI=YES
- mingw32-make is used to compile the firmware.
mingw32-make -C [path to build folder] -j [number of threads] firmware
For example, to compile the firmware using eight threads:
mingw32-make -C C:\Temp\OpenTX-Firmware -j 8 firmware
If the compilation succeeds, firmware.bin
will be located in the root of the build folder.
@ECHO OFF
REM Path where the firmware will be built
SET BUILDPATH=C:\Temp\OpenTX-Firmware
REM Path where the OpenTX source can be found
SET SRCPATH=%USERPROFILE%\GitHub\opentx
REM Path where the Qt compiler tools can be found
SET QTPATH=C:\Qt\5.15.2
REM Firmware build options
SET CMAKEOPTIONS=-DDISABLE_COMPANION=YES -DPCB=X10 -DPCBREV=TX16S -DINTERNAL_MODULE_MULTI=YES
REM Make the Firmware build folder
MKDIR %BUILDPATH%
REM Include GNU ARM Toolchain in the path
SET PATH=%PATH%;C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\bin
SET C_INCLUDE_PATH=C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include
SET CPLUS_INCLUDE_PATH=C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include\c++\4.7.4;C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include\c++\4.7.4\arm-none-eabi
REM Configure the build
cmake -G "MinGW Makefiles" -S %SRCPATH% -B %BUILDPATH% -DCMAKE_PREFIX_PATH=%QTPATH%\msvc2019 %CMAKEOPTIONS%
REM Build the firmware, using the maximum number of cores
mingw32-make -C %BUILDPATH% -j %NUMBER_OF_PROCESSORS% firmware
For the following steps open a cmd.exe Prompt by using Right click and select Run as administrator
- cmake is used to configure the build. It will create a Visual Studio solution file and several project files.
cmake -A win32 -S [path to source] -B [path to build folder] -DCMAKE_PREFIX_PATH=[path to Qt MSVC2019 folder] [build options]
For example, to configure the build for the RadioMaster TX16S (in order to build the TX16S simulator library):
cmake -A win32 -S C:\Temp\opentx -B C:\Temp\OpenTX-Companion -DCMAKE_PREFIX_PATH=C:\qt\5.15.2\msvc2019 -DPCB=X10 -DPCBREV=TX16S -DINTERNAL_MODULE_MULTI=YES
A second example, to configure build for Taranis X9D+ (not 2019) with "noheli" option (and to build the X9D+ sim library):
cmake -A win32 -S C:\Temp\opentx -B C:\Temp\OpenTX-Companion -DCMAKE_PREFIX_PATH=C:\qt\5.15.2\msvc2019 -DPCB=X9D+ -DPCBREV=2014 -DHELI=NO
The easiest way to compile Companion is by building the INSTALL project.
At the end of the build the Companion and Simulator executable files will be in the Releases sub-folder of the build folder.
Note: At this time building the INSTALL project does not actually put all the required DLL files in the output folder. A simple way to overcome this is to build the project using a script which finishes the build by putting all the dependencies in the Releases folder.
@ECHO OFF
REM Path where Companion will be built
SET BUILDPATH=C:\Temp\OpenTX-Companion
REM Path where the OpenTX source can be found
SET SRCPATH=%USERPROFILE%\GitHub\opentx
REM Path where the Qt compiler tools can be found
SET QTPATH=C:\Qt\5.15.2
REM Companion build options
SET CMAKEOPTIONS=-DPCB=X10 -DPCBREV=TX16S -DINTERNAL_MODULE_MULTI=YES
REM SET CMAKEOPTIONS=-DPCB=X9D+ -DPCBREV=2014 -DHELI=NO
REM Make the Companion build folder
MKDIR %BUILDPATH%
REM Import the Visual Studio command line build environment
CALL "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsMSBuildCmd.bat"
REM Configure the build
cmake -A win32 -S %SRCPATH% -B %BUILDPATH% -DCMAKE_PREFIX_PATH=%QTPATH%\msvc2019 %CMAKEOPTIONS%
REM Build the INSTALL project
msbuild %BUILDPATH%\INSTALL.vcxproj /t:Build /p:Configuration=Release
REM Move the resource DLLs into the Release folder
MOVE %BUILDPATH%\*.dll %BUILDPATH%\Release
REM Install the Qt dependencies in the Release folder
%QTPATH%\msvc2019\bin\windeployqt.exe --no-translations --no-opengl-sw --no-system-d3d-compiler --no-angle --no-compiler-runtime -dir "%BUILDPATH%\Release" %BUILDPATH%\Release\companion.exe %BUILDPATH%\Release\simulator.exe
Building Companion on Windows 32bit system you may encounter:
- fatal error C1060: compiler is out of heap space
- Open a cmd.exe Prompt by using Right click and select Run as administrator
- C:\ >
bcdedit /set IncreaseUserVa 3072
- Restart Windows to enable access to 3GB switch in Win 32bit systems