Compile on Windows: Difference between revisions

From LabRPS Documentation
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{Docnav
{{Docnav
|[[Licence|Licence]]
|[[License|License]]
|[[Compile_on_Linux|Compile on Linux]]
|[[Compile_on_Linux|Compile on Linux]]
}}
}}
Line 6: Line 6:
{{TOCright}}
{{TOCright}}


This page explains step by step '''how to compile LabRPS 0.001 or newer on Windows''' using using MinGW. For other platforms see [[Compiling|Compiling]].
This page explains step by step '''how to compile LabRPS 0.1.0 on Windows''' using Microsoft's MSVC compiler. For information on using MSYS2/MinGW see [[Compile_on_MinGW|Compile on MinGW]]. For other platforms see [[Compiling|Compiling]].


== Prerequisites ==  
== Prerequisites ==  
Line 12: Line 12:
Compiling LabRPS on Windows requires several tools and libraries.
Compiling LabRPS on Windows requires several tools and libraries.


* A compiler. LabRPS is tested with MinGW—other compilers may work, but instructions for their use are not included here. More details in [[#Compiler]], below.
===Required===


* [https://www.qt.io/ Qt for C++ (>=4.3)].
* A compiler. LabRPS is tested with Visual Studio (MSVC)—other compilers may work, but instructions for use are not included here. Fore more details, see the section [[#Compiler|Compiler]] below.


* [http://qwt.sourceforge.net/index.html Qwt (>=5.1.0)].
* [http://git-scm.com/ Git] (There are also GUI frontends available for Git, see the next section.)


* [http://qwtplot3d.sourceforge.net/ QwtPlot3D (>=0.2.6)].
* [https://cmake.org/download/ CMake] version 3.11.x or newer. </br> ''Hint:'' Choosing the option ''Add CMake to the system PATH for all users'' when installing CMake will make CMake accessible from the Windows command prompt, which can be useful.


* [http://www.gnu.org/software/gsl/ GSL (>=1.8)].
* The [https://github.com/LabRPS/LibPack LibPack]. This is a single package containing all of the libraries necessary to compile LabRPS on Windows. Download the version of the LibPack that corresponds to the version of LabRPS you want to compile. To compile LabRPS 0.1.0 download the [https://github.com/LabRPS/LibPack/releases/tag/v1.0.0 LibPack version 1.0.0]. Extract the LibPack to a convenient location. (If your computer does not recognize the .7z extension, you must install the program [https://www.7-zip.org 7-zip].) </br> '''Note''': It is highly recommended to compile LabRPS with the compiler version the LibPack is designed for. For example, you might run into problems compiling LabRPS 0.1.0 using MSVC&nbsp;2017 because the LibPack is designed to be built with MSVC&nbsp;2022 or newer.</br>


* [http://beltoforion.de/en/muparser/ muParser (>=1.28)].
===Optional programs===


* [http://www.zlib.net/ zlib (>=1.2.3)].
* A GUI frontend for Git. There are several frontends available, see [https://en.wikipedia.org/wiki/Comparison_of_Git_GUIs this list]. The main benefit of a frontend is that you don't have to learn the Git commands to get the source code of LabRPS or to send patches to the GitHub repository of LabRPS.


QwtPlot3D and Qwt must be compiled against Qt 5.x! If these are compiled with Qt3 or Qt4, the application might crash.
In the following we describe source code handling using the [https://tortoisegit.org/ TortoiseGit] frontend. This frontend integrates directly into Windows file explorer and has a large user community to get help in case you have problems.


==Source code==  
* [http://sourceforge.net/projects/nsis/ NSIS] is used to generate the LabRPS Windows installer.
 
===Source code===  


Now you can get the source code of LabRPS:
Now you can get the source code of LabRPS:
Line 37: Line 39:
# Create a new folder where the source code will be downloaded.
# Create a new folder where the source code will be downloaded.
# Right-click on this folder in the Windows file explorer and select '''Git Clone''' in the context menu.
# Right-click on this folder in the Windows file explorer and select '''Git Clone''' in the context menu.
# A dialog will appear. In it, enter the URL for the LabRPS Git repository: {{URL|https://github.com/LabRPS/LabRPS.git}}.<br>
# A dialog will appear. In it, enter the URL for the LabRPS Git repository
 
''https://github.com/LabRPS/LabRPS.git''


and click '''OK'''.
and click '''OK'''.
Line 51: Line 55:
}}
}}


==Building LabRPS==
===Compiler===
 
The default (recommended) compiler is MS Visual Studio (MSVC). Though it may be possible to use other compilers, for example gcc via Cygwin or MinGW, it is not tested or covered here.
 
You can get a free version of MSVC (for individual usage) by downloading the [https://visualstudio.microsoft.com/vs/community/ ''Community'' edition of MS Visual Studio].
 
For those who want to avoid installing the huge MSVC for the mere purpose of having a compiler, see [[CompileOnWindows - Reducing Disk Footprint]].
 
'''Note:''' Although the ''Community'' edition of MSVC is free, to use the IDE for more than a 30-day trial period you must create a Microsoft account. If you will only compile using the command line, you don't need the IDE and thus no Microsoft account.
 
As a free and OpenSource alternative IDE you can use [https://www.kdevelop.org/download KDevelop]. You can use KDevelop to modify and write C++ code but must use the command line to compile.
 
===Optional system path configuration===
 
Optionally you can include the paths to some folders to the system PATH variable. This is helpful if you want to access programs in these folders from the command line/powershell or if you want special programs to be found by the compiler or CMake. Besides this, adding folders to the PATH might be necessary if you did not use the corresponding options when installing the program.
 
* You can include the folder of your LibPack in your system PATH variable. This is useful if you plan to build multiple configurations/versions of LabRPS.
* If you did not use the option to add CMake to the PATH while installing it, add its installation folder
 
''C:\Program Files\CMake\bin'' to the PATH.
* If you did not use the option to add TortoiseGit to the PATH while installing it, add its installation folder
 
''C:\Program Files\TortoiseGit\bin'' to the PATH.
 
To add folder paths to the PATH variable:
# In the Windows Start menu Right click on ''Computer'' and choose ''Properties''.
# In the appearing dialog click on ''Advanced system settings''.
# Another dialog will open. Click there in the tab ''Advanced'' on '''Environment Variables'''.
# Again another dialog will open. Select then the variable ''Path'' and click on '''Edit'''.
# And again another dialog will open. Click there on '''New''' and add to path to the folder of Git or the LibPack.
# Finally press '''OK''' and close all dialogs by pressing '''OK''' as well.
 
== Configuration ==
 
Once you have all of the necessary tools, libraries, and LabRPS source code, you are ready to begin the configuration and compilation process. This process will proceed in five steps:
# Run CMake once to examine your system and begin the configuration progress (this will report that it failed).
# Adjust necessary CMake settings to set the locations of the LibPack and enable Qt5.
# Re-run CMake to finalize the configuration (this time it should succeed).
# Use CMake to generate the Visual Studio build system.
# Use Visual Studio to build LabRPS.
 
===CMake===  


# Download the "Qt/Windows Open Source Edition" from {{URL|https://www.qt.io/}}. It comes with a graphical installer. When the Qt installer asks you to install MinGW, say yes unless you already have it on your system. In that case you have to tell the Qt installer where to find it. In the case that PyQt (see blow) does not yet support the latest version of Qt, you can get older versions here: {{URL|ftp://ftp.trolltech.com/qt/source/}}
First, configure the build environment using CMake:
# Download Python from {{URL|http://www.python.org/download/}} and install it.
# Open the CMake GUI
# Download the source code of LabRPS from {{URL|http://LabRPS.sourceforge.net/download.html}} and unpack it.
# Specify the source folder of LabRPS.
#. Download the SIP source code for Windows from {{URL|http://www.riverbankcomputing.co.uk/software/sip/download}} and unpack it into the 3rdparty subfolder of the LabRPS package. Rename the "sip-x.y" directory that gets created to "sip".
# Specify a build folder. This can be '''build''' in the folder you cloned the repo because this path is ignored by git. Do not use the source folder. CMake will create this folder if it does not exist.
# Download the PyQt v4 source code for Windows from {{URL|http://www.riverbankcomputing.co.uk/software/pyqt/download}} and unpack it into the 3rdparty subfolder of the LabRPS package. Rename the "PyQt-win-gpl-x.y.z" directory that gets created to "PyQt-win-gpl".
# Click '''Configure'''.
# Download the "Developer files" of the GSL from {{URL|http://gnuwin32.sourceforge.net/packages/gsl.htm}} and unpack them into the 3rdparty subfolder of the LabRPS package.
# In the dialog that appears specify the generator you want to use: in most cases you will use the defaults in this dialog. For the standard MS Visual Studio use ''Visual Studio xx 2yyy'' where xx is the compiler version and 2yyy the year of its release. It is recommended to use the default option ''Use default native compilers''.
# Download the source code of the latest version of Qwt from {{URL|https://sourceforge.net/projects/qwt/files/}} and unpack it into the 3rdparty subfolder of the LabRPS package. Rename the "qwt-x.y.z" directory that gets created to "qwt".
 
# Download the source code of QwtPlot3D from {{URL|http://qwtplot3d.sourceforge.net/web/navigation/download_frame.html}} and unpack it into the 3rdparty subfolder of the LabRPS package.
'''Note:''' It is important to specify the correct bit variant. If you have the 64-bit variant of the LibPack you must also use the x64 compiler.
# Download the source code of muParser from {{URL|https://sourceforge.net/projects/muparser/files/}} and unpack it into the 3rdparty subfolder of the LabRPS package. Rename the "muparser_vxyz" directory that gets created to "muparser".
 
# Open the start menu, find the folder created by the Qt SDK and start a "Qt Command Prompt". Execute "cd <directory containing LabRPS sources>", then "build". LabRPS and its dependencies should be built automatically and installed into the directory "output".
This will begin the configuration and ''will fail'' because of missing settings. This is normal, you have not yet specified the location of the LibPack. However, there are other failures that might occur that require some further action on your part.
 
If it fails with the message that Visual Studio could not be found, the CMake support in MSVC is not yet installed. To do this:
# Open the MSVC IDE
# Use the menu Tools → Get Tools and Features
# In the ''Workloads'' tab enable ''Desktop development with C++''
# On the right side you should now see that the component ''Visual C++ tools for CMake'' will be installed.
# Install it.
 
If it fails with a message about the wrong Python version or missing Python, then:
# Use the "Search:" box in CMake to search for the string "Python"
# If you see there a path like ''C:/Program Files/Python38/python.exe'', CMake recognized the Python that is already installed on your PC, but that version is not compatible with the LibPack. Since the LibPack includes a compatible version of Python, modify the following Python settings in CMake to its paths (assuming the LibPack is in the folder ''D:/LabRPS-build/LabRPSLibs_1_0_0_x64_VC2022''):
[[File:CMake_Python_settings.png]]
 
If there is no error about Visual Studio or Python, everything is fine, but CMake does not yet know all necessary settings. Therefore now:
# Search in CMake for the variable '''LABRPS_LIBPACK_DIR''' and specify the location of the LibPack folder you downloaded earlier.
# Search for the variable '''BUILD_QT5''' and enable this option.
# (''If planning on running directly from the build folder such as for debugging'') Search for and enable the following options:
#* '''LABRPS_COPY_DEPEND_DIRS_TO_BUILD'''
#* '''LABRPS_COPY_LIBPACK_BIN_TO_BUILD'''
#* '''LABRPS_COPY_PLUGINS_BIN_TO_BUILD'''
# Click '''Configure''' again.
 
There should now be no errors. If you continue to encounter errors that you cannot diagnose, visit the [https://labrps.com/boards Install/Compile forum] on the LabRPS forum website. If CMake proceeded correctly, click on '''Generate'''. After this is done you can close CMake and start the compilation of LabRPS using Visual Studio. However, for the first compilation keep it open in case you want or need to change some options for the build process.
 
=== Options for the build process ===
 
The CMake build system gives you control over some aspects of the build process. In particular, you can switch on and off some features or modules using CMake variables.
 
Here is a description of some of these variables:
 
{| class="wikitable" style="text-align:left"
|-
! Variable name      !! Description  !! Default
|-
| BUILD_XXX || Build LabRPS with the component XXX. If you don't want/need to compile e.g. the workbench ''Plot'', disable the variable ''BUILD_PLOT''. LabRPS will then not have this workbench.
'''Note:''' Some components are required for other components. If you for example uncheck ''BUILD_WEB'' CMake will inform you that then the component ''BUILD_START'' cannot be compiled correctly. Therefore check the CMake output after you changed a BUILD_XXX option!
|| depends
|-
| BUILD_ENABLE_CXX_STD || The version of the C++ language standard. At least '''C++17''' is required for LabRPS 0.1.0.  
|| depends
|-
| BUILD_DESIGNER_PLUGIN|| To build the Qt Designer plugin, see [[Compile_on_Windows#Qt_Designer_plugin|this section below]] || OFF
|-
| CMAKE_INSTALL_PREFIX  || The output folder when building the target ''INSTALL'', see also the section [[#Running and installing LabRPS|Running and installing LabRPS]] || Windows default program installation folder
|-
| LABRPS_COPY_DEPEND_DIRS_TO_BUILD || Copies depending libraries needed to execute the LabRPS.exe to the build folder. See also the section [[#Running and installing LabRPS|Running and installing LabRPS]].</br> '''Note:''' the options LABRPS_COPY_XXX only appear if the libraries were not already copied. If you want to bring back the options for some reason, you need to delete all folders in your build folder, except for the LibPack folder. In CMake delete the cache and start as if you compile for the first time. || OFF
|-
| LABRPS_COPY_LIBPACK_BIN_TO_BUILD || Copies the LibPack binaries needed to execute the LabRPS.exe to the build folder. See also the section [[#Running and installing LabRPS|Running and installing LabRPS]]. || OFF
|-
| LABRPS_COPY_PLUGINS_BIN_TO_BUILD|| Copies Qt's plugin files needed to execute the LabRPS.exe to the build folder. See also the section [[#Running and installing LabRPS|Running and installing LabRPS]]. || OFF
|-
| LABRPS_LIBPACK_USE || Switch the usage of the LabRPS LibPack on or off  || ON
|-
| LABRPS_LIBPACK_DIR || Directory where the LibPack is || LabRPS's source code folder
|-
| LABRPS_RELEASE_PDB || Create debug libraries (*.pdb) also for release builds. It doesn't affect the speed (like a real debug build would do) and can be very useful to locate crashes in LabRPS code. In case LabRPS crashes a ''crash.dmp'' file will be created that can be loaded with MSVC and if you have the corresponding PDB files plus the source code of that version you can debug through the code. Without the PDB files it's not possible to debug the code and all what the debugger shows is the name of the DLL where the crash has occurred. || ON
|-
| LABRPS_USE_MP_COMPILE_FLAG || Adds the /MP (multiprocessor) option to the Visual Studio projects, enabling speedups on multi-core CPUs. This can greatly accelerate builds on modern processors.</br>'''Note:''' If you turn off '''LABRPS_USE_PCH''', the compilation can quickly overload your heap space, even if you have 16 GB RAM. || ON
|-
| LABRPS_USE_PCH || [https://en.wikipedia.org/wiki/Precompiled_header Precompiles the headers] in order to save compilation time. || ON
|-
| LABRPS_USE_PYBIND11|| Includes the [https://github.com/pybind/pybind11 PyBind11] library. '''Note:''' after turning it on you might get a configuration error. Just configure again and the problem should go away. || OFF
|}
 
== Building LabRPS ==
 
Depending on your compiler, the process for building LabRPS will be slightly different. In the following sections known workflows are described. If you want to build with Qt Creator, it is possible but it has not been tested, otherwise proceed directly:
 
=== Building from cmd.exe command line ===
 
If you want to build from the command line, CMake output will show you the proper command to run (which depends on the configured release directory). But this command will produce a ''Debug'' build which does not work on Windows and results in a Numpy import error in LabRPS (which is a known issue but hard to fix). You need to specify the ''--config Release'' option to force a ''Release'' build:


== Windows(cross compile on linux using MXE) ==
MXE is a version of MinGW that has been compiled on Linux and acts as a cross-compilation environment targeting the Windows operating system. More details can be found at {{URL|http://mxe.cc/}}
<ol>
  <li>Install all dependencies required for MXE according to your linux distro as described [http://mxe.cc/#requirements here]</li>
  <li>Download current version of MXE(lets use the home directory $HOME)</li>
  {{Code|code=
cd ~
git clone https://github.com/mxe/mxe.git
cd mxe
}}
  <li>Install dependencies required by Labrps(this may take some time)</li>
{{Code|code=
{{Code|code=
make qt gsl zlib muparser
cmake --build E:/release --config Release
}}
}}
  <li>Create a symbolic link of MXE version of qmake(qt4) & minGW and copy it to /bin directory   
 
Note:Qt 4 is in the "qt" subdirectory. Qt 5 is in the "qt5" subdirectory (use QT4)</li>
Please note that setting CMake variables like ''CMAKE_BUILD_TYPE'' does not have any effect, only specifying the ''--config'' option as shown above works.
 
<div class="mw-collapsible mw-collapsed toccolours">
 
=== Building with Visual Studio 17 (2022) or newer ===
 
<div class="mw-collapsible-content">
 
==== Release Build ====
 
# Start the Visual Studio IDE. This can either be done by pressing the button ''Open Project'' in the CMake GUI or by double-clicking on the file ''LabRPS.sln'' that you find in your build folder.
# In the toolbar of the MSVC IDE assure that you use for the first compilation ''Release''.
# There is a window called ''Solution Explorer''. It lists all possible compilation targets. To start a full compilation, right-click on the target '''ALL_BUILD''' and then choose '''Build'''.
This will now take quite a long time.
 
To compile a ready-to use LabRPS, compile the target ''INSTALL'', see the section [[#Running and installing LabRPS|Running and installing LabRPS]].
 
If you don't get any errors you are done. '''Congratulations!''' You can exit MSVC or keep it open.
 
==== Debug Build ====
 
For a debug build it is necessary that the Python is used that is included in the LibPack. To assure this:
#  Search in the CMake GUI for "Python"
#  If you see there a path like ''C:/Program Files/Python38/python.exe'', CMake recognized the Python that is installed on your PC and not the one of the LibPack. In this case adapt these different Python settings in CMake to this (assuming the LibPack is in the folder ''D:\LabRPS-build\LabRPSLibs_1.0.0_x64_VC17''):
[[File:CMake_Python_settings.png]]
 
As prerequisite for the debug build, you need to do this:
# Copy the content of the LibPack folder ''bind'' to the ''bin'' folder of the LabRPS build folder (overwrite the existing files).
# Copy the content of the LibPack folder ''libd'' to the ''lib'' folder of the LabRPS build folder.
 
Now you can compile:
# Start the Visual Studio IDE. This can either be done by pressing the button ''Open Project'' in the CMake GUI or by double-clicking on the file ''LabRPS.sln'' that you find in your build folder.
# In the toolbar of the MSVC IDE assure that you use for the first compilation ''Debug''.
# There is a window called ''Solution Explorer''. It lists all possible compilation targets. To start a full compilation, right-click on the target '''ALL_BUILD''' and then choose '''Build''' in the context menu.
This will now take quite a long time.
 
If there were no compilation errors, and if the '''LABRPS_COPY_*''' options mentioned in the [[#CMake|CMake Configuration step]] above were enabled, you can start the debug build:
# Right-click on the target '''LabRPSMain''' and then choose '''Set as Startup Project''' in the context menu.
# Finally click in the toolbar on the button with the green triangle named '''Local Windows Debugger'''.
 
This will start the debug build of LabRPS and you can use the  MSVC IDE to debug it.
 
===Command line build===
 
<div class="mw-collapsible-content">
 
The steps how to compile from the command line depends on the compiler. For MSVC 2022 the steps are:
# In Windows start menu go to {{MenuCommand|Visual Studio 2022 → Visual Studio Tools}} and choose '''Developer Command Prompt for VS 2022'''
# Change to your build folder.
# Execute the command
 
{{Code|code=msbuild ALL_BUILD.vcxproj /p:Configuration=Release}}
 
or
 
{{Code|code=msbuild INSTALL.vcxproj /p:Configuration=Release}}
 
These steps can also be automaized. Here is for example a solution for MSVC 2022:
# Download the script [https://forum.freecadweb.org/download/file.php?id=92135 compile-FC.txt].
# Rename it to ''compile-FC.bat''
# In Windows file explorer Shift+Right-click on your build folder and use from the context menu ''Command prompt here''.
# Execute the command
 
{{Code|code=compile-FC install}}
 
Instead of calling '''compile-FC''' with the option ''install'' you can also use ''debug'' or ''release'':
 
''debug'' &nbsp; - compile LabRPS in debug configuration
 
''release'' - compile LabRPS in release configuration
 
''install'' &nbsp;&nbsp; - compile LabRPS in release configuration and create an install setup
 
</div>
</div>
 
==Running and installing LabRPS==
 
There are 2 methods to run the compiled LabRPS:
 
''Method 1'': You execute the LabRPS.exe that you find in your build folder in the subfolder ''bin''
 
''Method 2'': You build the target ''INSTALL''
 
Method 2 is the simpler one because it automatically assures that all libraries needed to run the LabRPS.exe are in the correct folder. The LabRPS.exe and the libraries will be output in the folder you specified in the CMake variable ''CMAKE_INSTALL_PREFIX''.
 
For Method 1 you need to enable the '''LABRPS_COPY_*''' options mentioned in the [[#CMake|CMake Configuration step]] above.
 
===Troubleshooting===
 
When running LabRPS you may encounter missing DLLs when using certain workbenches or features of workbenches. The error message in LabRPS's console will not tell you what DLL is missing. To find this out you must use an external tool:
 
* Download the latest release of the program '''Dependencies''': https://github.com/lucasg/Dependencies/releases (choose the file ''Dependencies_x64_Release.zip'')
* In the LabRPS [[Python console]] execute these commands:
<nowiki>import os
os.system(r"~\DependenciesGui.exe")</nowiki>
'''Note''': Instead of the ~ you must specify the full path to the ''DependenciesGui.exe'' on your system.
* Now drag in the *.pyd file of the workbench with which you get missing DLLs reported.
 
==Updating the build==
 
LabRPS is very actively developed. Therefore its source code changes almost daily. New features are added and bugs are fixed. To benefit from these source code changes, you must rebuild your LabRPS. This is done in two steps:
# Updating the source code
# Recompilation
 
===Updating the source code===
 
====Using a frontend====
 
When using the [https://en.wikipedia.org/wiki/Comparison_of_Git_GUIs Git frontend] TortoiseGit:
# Right-click on your LabRPS source code folder in the Windows file explorer and select '''Pull''' in the context menu.
# A dialog will appear. Select there what development branch you want to get. '''master''' is the main branch. Therefore use this unless you want to compile a special new feature from a branch that has not yet been merged to ''master''. (For more about Git branches, see [[Source_code_management#Git_development_process|Git development process]].)
 
Finally click '''OK'''.
 
====Using the command line====
 
Open a terminal (command prompt) and switch there to your source directory. Then type:
 
{{Code|code=
{{Code|code=
sudo ln -sf ~/mxe/usr/i686-w64-mingw32.static/qt/bin/qmake /bin/mxe-qmake-qt4
git pull https://github.com/LabRPS/LabRPS.git master
sudo ln -sf ~/mxe/usr/BIN/i686-w64-mingw32.static-g++ /bin/i686-w64-mingw32.static-g++
sudo ln -sf ~/mxe/usr/BIN/i686-w64-mingw32.static-gcc-ar /bin/i686-w64-mingw32.static-gcc-ar
}}
}}


  <li>Download QWT5 sources from {{URL|https://sourceforge.net/projects/qwt/files/qwt/5.2.1/}}, unpack, edit qwtconfig.pri & comment out the following lines:</li>
where ''master'' the the name of the main development branch. If you want to get code from another branch, use its name instead of ''master''.
{{Code|code=
 
#CONFIG += thread
==Tools==  
#CONFIG += QwtDll
 
}}
In order to join the LabRPS development you should compile and install the following tools:
  <li>open terminal, get in to qwt5 directory & start build</li>
 
{{Code|code=
===Qt Designer plugin===  
mxe-qmake-qt4
 
make
LabRPS uses [https://en.wikipedia.org/wiki/Qt_(software) Qt] as toolkit for its user interface. All dialogs are setup in UI-files that can be edited using the program [https://doc.qt.io/qt-5/qtdesigner-manual.html Qt Designer] that is part of any Qt installation and also included in the LibPack. LabRPS has its own set of Qt widgets to provide special features like adding a unit to input fields and to set preferences properties.
}}
 
  <li>Download qwtplot3d sources from {{URL|https://sourceforge.net/projects/qwtplot3d/}}, unpack, edit qwtplot3d.pro & comment out the following lines:</li>
====Compilation====  
{{Code|code=
 
#win32:TEMPLATE    = vclib
The plugin cannot be loaded by the Qt Designer if it was compiled using another Qt version than the one your Qt Designer/Qt Creator is based on. Therefore the plugin must be compiled together with LabRPS:
#win32:CONFIG    += dll exceptions
 
#win32:dll:DEFINES    += QT_DLL QWT3D_DLL QWT3D_MAKEDLL
* In the CMake options (see [[Compile_on_Windows#Options_for_the_build_process|this section above]]) enable the option BUILD_DESIGNER_PLUGIN and reconfigure.
}}
* open MSVC and build the target '''LabRPS_widgets'''
Note: patches may be required.. for eg arch based systems may need [https://projects.archlinux.org/svntogit/packages.git/tree/trunk/qwtplot3d-gcc44.patch?h=packages/qwtplot3d https://projects.archlinux.org/svntogit/packages.git/tree/trunk/qwtplot3d-gcc44.patch?h=packages/qwtplot3d] & [https://projects.archlinux.org/svntogit/packages.git/tree/trunk/qwtplot3d-qt-4.8.0.patch?h=packages/qwtplot3d https://projects.archlinux.org/svntogit/packages.git/tree/trunk/qwtplot3d-qt-4.8.0.patch?h=packages/qwtplot3d]
 
<li>open terminal, get in to qwtplot3d directory & start build</li>
As result you will get the plugin file '''LabRPS_widgets.dll'' in the folder</br>''~\src\Tools\plugins\widget\Release''
{{Code|code=
 
mxe-qmake-qt4
====Installation====  
make
 
}}
To install the plugin, copy the DLL either to:
  <li>Download latest sources of LabRPS(lets use the home directory $HOME)</li>
* If you use the LibPack: to the folder</br>''~\LabRPSLibs_1_0_0_x64_VC2022\plugins\designer''
{{Code|code=
* If you have a full Qt installation: you can choose between the folder</br>''C:\Qt\5.15.2\msvc2022_64\plugins\designer''</br>or</br>''C:\Qt\5.15.2\msvc2022_64\bin\designer'' (you must first create the ''designer'' subfolder.)</br>(adapt the paths to your installation!).
cd ~
git clone https://github.com/LabRPS/LabRPS.git
}}
  <li>create include & lib directory inside ~/LabRPS/3rdparty/</li>
  <li>copy contents of src directory(only *.h files) inside qwtplot3d to ~/LabRPS/3rdparty/include</li>
  <li>copy contents of include directory inside qwtplot3d to ~/LabRPS/3rdparty/include</li>
  <li>copy lib/libqwt.a inside qwt to ~/LabRPS/3rdparty/lib</li>
  <li>copy lib/libqwtplot3d.a inside qwtplot3d to ~/LabRPS/3rdparty/lib</li>
  <li>now we can build LabRPS</li>
{{Code|code=
cd ~/LabRPS
mxe-qmake-qt4
make
}}
After build process you will get LabRPS.exe inside ~/LabRPS/LabRPS directory...
</ol>


==Additional information==
Finally (re)start Qt Designer and check its menu {{MenuCommand|Help → Plugins}}. If the plugin '''LabRPS_widgets.dll''' is listed as being loaded, you can now design and change LabRPS's .ui files. If not, you must [[#Compilation|compile]] the DLL by yourself.


# Forums and mailing lists If you want to discuss LabRPS with other users (or the developers) or if you are insterested in its further development, you can go to the [http://labrps.com/boards LabRPS forum].
If you prefer using [https://en.wikipedia.org/wiki/Qt_Creator Qt Creator] instead of Qt Designer, the plugin file must be placed in this folder:</br>''C:\Qt\Qt5.15.2\Tools\QtCreator\bin\plugins\designer''</br>Then (re)start Qt Creator, switch to the mode '''Design''' and then check the menu {{MenuCommand|Tools → Form Editor → About Qt Designer Plugins}}. If the plugin '''LabRPS_widgets.dll''' is listed as being loaded, you can now design and change LabRPS's .ui files. If not, you must [[#Compilation|compile]] the DLL by yourself.
# License LabRPS is distributed under the terms of the [http://www.gnu.org/licenses/gpl.html GNU General Public License] as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. A copy of this license is provided in the file `gpl.txt`.


Thus it is [http://www.fsf.org/licensing/essays/free-sw.html "free software"]. "Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech", not as in "free beer". "Free software" is also often called [http://en.wikipedia.org/wiki/Alternative_terms_for_free_software Open Source, FOSS, or FLOSS]. When we say that LabRPS is "free", we are talking about
== References ==


*  The freedom to run the program, for any purpose (freedom 0).
See also
*  The freedom to study how the program works, and adapt it to your needs (freedom 1). Access to the source code is a precondition for this.
* [[Compiling_(Speeding_up)|Compiling - Speeding up]]
*  The freedom to redistribute copies so you can help your neighbor (freedom 2).
*   The freedom to improve the program, and release your improvements to the public, so that the whole community benefits (freedom 3). Access to the source code is a precondition for this.


That said, LabRPS is also free as in "free beer". We do not charge money for anything you can download on our homepage and we will not do so in the future.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


{{Docnav
{{Docnav
|[[Licence|Licence]]
|[[License|License]]
|[[Compile_on_Linux|Compile on Linux]]
|[[Compile_on_Linux|Compile on Linux]]
}}
}}

Revision as of 05:11, 26 November 2024

Arrow-left.svg Previous: License

This page explains step by step how to compile LabRPS 0.1.0 on Windows using Microsoft's MSVC compiler. For information on using MSYS2/MinGW see Compile on MinGW. For other platforms see Compiling.

Prerequisites

Compiling LabRPS on Windows requires several tools and libraries.

Required

  • A compiler. LabRPS is tested with Visual Studio (MSVC)—other compilers may work, but instructions for use are not included here. Fore more details, see the section Compiler below.
  • Git (There are also GUI frontends available for Git, see the next section.)
  • CMake version 3.11.x or newer.
    Hint: Choosing the option Add CMake to the system PATH for all users when installing CMake will make CMake accessible from the Windows command prompt, which can be useful.
  • The LibPack. This is a single package containing all of the libraries necessary to compile LabRPS on Windows. Download the version of the LibPack that corresponds to the version of LabRPS you want to compile. To compile LabRPS 0.1.0 download the LibPack version 1.0.0. Extract the LibPack to a convenient location. (If your computer does not recognize the .7z extension, you must install the program 7-zip.)
    Note: It is highly recommended to compile LabRPS with the compiler version the LibPack is designed for. For example, you might run into problems compiling LabRPS 0.1.0 using MSVC 2017 because the LibPack is designed to be built with MSVC 2022 or newer.

Optional programs

  • A GUI frontend for Git. There are several frontends available, see this list. The main benefit of a frontend is that you don't have to learn the Git commands to get the source code of LabRPS or to send patches to the GitHub repository of LabRPS.

In the following we describe source code handling using the TortoiseGit frontend. This frontend integrates directly into Windows file explorer and has a large user community to get help in case you have problems.

  • NSIS is used to generate the LabRPS Windows installer.

Source code

Now you can get the source code of LabRPS:

Using a frontend

When using the Git frontend TortoiseGit:

  1. Create a new folder where the source code will be downloaded.
  2. Right-click on this folder in the Windows file explorer and select Git Clone in the context menu.
  3. A dialog will appear. In it, enter the URL for the LabRPS Git repository

https://github.com/LabRPS/LabRPS.git

and click OK.

The latest source code will be downloaded from the LabRPS Git repository and the folder will be tracked by Git.

Using the command line

To create a local tracking branch and download the source code, open a terminal (command prompt) and switch there to the directory you want the source, then type:

git clone https://github.com/LabRPS/LabRPS.git

Compiler

The default (recommended) compiler is MS Visual Studio (MSVC). Though it may be possible to use other compilers, for example gcc via Cygwin or MinGW, it is not tested or covered here.

You can get a free version of MSVC (for individual usage) by downloading the Community edition of MS Visual Studio.

For those who want to avoid installing the huge MSVC for the mere purpose of having a compiler, see CompileOnWindows - Reducing Disk Footprint.

Note: Although the Community edition of MSVC is free, to use the IDE for more than a 30-day trial period you must create a Microsoft account. If you will only compile using the command line, you don't need the IDE and thus no Microsoft account.

As a free and OpenSource alternative IDE you can use KDevelop. You can use KDevelop to modify and write C++ code but must use the command line to compile.

Optional system path configuration

Optionally you can include the paths to some folders to the system PATH variable. This is helpful if you want to access programs in these folders from the command line/powershell or if you want special programs to be found by the compiler or CMake. Besides this, adding folders to the PATH might be necessary if you did not use the corresponding options when installing the program.

  • You can include the folder of your LibPack in your system PATH variable. This is useful if you plan to build multiple configurations/versions of LabRPS.
  • If you did not use the option to add CMake to the PATH while installing it, add its installation folder

C:\Program Files\CMake\bin to the PATH.

  • If you did not use the option to add TortoiseGit to the PATH while installing it, add its installation folder

C:\Program Files\TortoiseGit\bin to the PATH.

To add folder paths to the PATH variable:

  1. In the Windows Start menu Right click on Computer and choose Properties.
  2. In the appearing dialog click on Advanced system settings.
  3. Another dialog will open. Click there in the tab Advanced on Environment Variables.
  4. Again another dialog will open. Select then the variable Path and click on Edit.
  5. And again another dialog will open. Click there on New and add to path to the folder of Git or the LibPack.
  6. Finally press OK and close all dialogs by pressing OK as well.

Configuration

Once you have all of the necessary tools, libraries, and LabRPS source code, you are ready to begin the configuration and compilation process. This process will proceed in five steps:

  1. Run CMake once to examine your system and begin the configuration progress (this will report that it failed).
  2. Adjust necessary CMake settings to set the locations of the LibPack and enable Qt5.
  3. Re-run CMake to finalize the configuration (this time it should succeed).
  4. Use CMake to generate the Visual Studio build system.
  5. Use Visual Studio to build LabRPS.

CMake

First, configure the build environment using CMake:

  1. Open the CMake GUI
  2. Specify the source folder of LabRPS.
  3. Specify a build folder. This can be build in the folder you cloned the repo because this path is ignored by git. Do not use the source folder. CMake will create this folder if it does not exist.
  4. Click Configure.
  5. In the dialog that appears specify the generator you want to use: in most cases you will use the defaults in this dialog. For the standard MS Visual Studio use Visual Studio xx 2yyy where xx is the compiler version and 2yyy the year of its release. It is recommended to use the default option Use default native compilers.

Note: It is important to specify the correct bit variant. If you have the 64-bit variant of the LibPack you must also use the x64 compiler.

This will begin the configuration and will fail because of missing settings. This is normal, you have not yet specified the location of the LibPack. However, there are other failures that might occur that require some further action on your part.

If it fails with the message that Visual Studio could not be found, the CMake support in MSVC is not yet installed. To do this:

  1. Open the MSVC IDE
  2. Use the menu Tools → Get Tools and Features
  3. In the Workloads tab enable Desktop development with C++
  4. On the right side you should now see that the component Visual C++ tools for CMake will be installed.
  5. Install it.

If it fails with a message about the wrong Python version or missing Python, then:

  1. Use the "Search:" box in CMake to search for the string "Python"
  2. If you see there a path like C:/Program Files/Python38/python.exe, CMake recognized the Python that is already installed on your PC, but that version is not compatible with the LibPack. Since the LibPack includes a compatible version of Python, modify the following Python settings in CMake to its paths (assuming the LibPack is in the folder D:/LabRPS-build/LabRPSLibs_1_0_0_x64_VC2022):

File:CMake Python settings.png

If there is no error about Visual Studio or Python, everything is fine, but CMake does not yet know all necessary settings. Therefore now:

  1. Search in CMake for the variable LABRPS_LIBPACK_DIR and specify the location of the LibPack folder you downloaded earlier.
  2. Search for the variable BUILD_QT5 and enable this option.
  3. (If planning on running directly from the build folder such as for debugging) Search for and enable the following options:
    • LABRPS_COPY_DEPEND_DIRS_TO_BUILD
    • LABRPS_COPY_LIBPACK_BIN_TO_BUILD
    • LABRPS_COPY_PLUGINS_BIN_TO_BUILD
  4. Click Configure again.

There should now be no errors. If you continue to encounter errors that you cannot diagnose, visit the Install/Compile forum on the LabRPS forum website. If CMake proceeded correctly, click on Generate. After this is done you can close CMake and start the compilation of LabRPS using Visual Studio. However, for the first compilation keep it open in case you want or need to change some options for the build process.

Options for the build process

The CMake build system gives you control over some aspects of the build process. In particular, you can switch on and off some features or modules using CMake variables.

Here is a description of some of these variables:

Variable name Description Default
BUILD_XXX Build LabRPS with the component XXX. If you don't want/need to compile e.g. the workbench Plot, disable the variable BUILD_PLOT. LabRPS will then not have this workbench.

Note: Some components are required for other components. If you for example uncheck BUILD_WEB CMake will inform you that then the component BUILD_START cannot be compiled correctly. Therefore check the CMake output after you changed a BUILD_XXX option!

depends
BUILD_ENABLE_CXX_STD The version of the C++ language standard. At least C++17 is required for LabRPS 0.1.0. depends
BUILD_DESIGNER_PLUGIN To build the Qt Designer plugin, see this section below OFF
CMAKE_INSTALL_PREFIX The output folder when building the target INSTALL, see also the section Running and installing LabRPS Windows default program installation folder
LABRPS_COPY_DEPEND_DIRS_TO_BUILD Copies depending libraries needed to execute the LabRPS.exe to the build folder. See also the section Running and installing LabRPS.
Note: the options LABRPS_COPY_XXX only appear if the libraries were not already copied. If you want to bring back the options for some reason, you need to delete all folders in your build folder, except for the LibPack folder. In CMake delete the cache and start as if you compile for the first time.
OFF
LABRPS_COPY_LIBPACK_BIN_TO_BUILD Copies the LibPack binaries needed to execute the LabRPS.exe to the build folder. See also the section Running and installing LabRPS. OFF
LABRPS_COPY_PLUGINS_BIN_TO_BUILD Copies Qt's plugin files needed to execute the LabRPS.exe to the build folder. See also the section Running and installing LabRPS. OFF
LABRPS_LIBPACK_USE Switch the usage of the LabRPS LibPack on or off ON
LABRPS_LIBPACK_DIR Directory where the LibPack is LabRPS's source code folder
LABRPS_RELEASE_PDB Create debug libraries (*.pdb) also for release builds. It doesn't affect the speed (like a real debug build would do) and can be very useful to locate crashes in LabRPS code. In case LabRPS crashes a crash.dmp file will be created that can be loaded with MSVC and if you have the corresponding PDB files plus the source code of that version you can debug through the code. Without the PDB files it's not possible to debug the code and all what the debugger shows is the name of the DLL where the crash has occurred. ON
LABRPS_USE_MP_COMPILE_FLAG Adds the /MP (multiprocessor) option to the Visual Studio projects, enabling speedups on multi-core CPUs. This can greatly accelerate builds on modern processors.
Note: If you turn off LABRPS_USE_PCH, the compilation can quickly overload your heap space, even if you have 16 GB RAM.
ON
LABRPS_USE_PCH Precompiles the headers in order to save compilation time. ON
LABRPS_USE_PYBIND11 Includes the PyBind11 library. Note: after turning it on you might get a configuration error. Just configure again and the problem should go away. OFF

Building LabRPS

Depending on your compiler, the process for building LabRPS will be slightly different. In the following sections known workflows are described. If you want to build with Qt Creator, it is possible but it has not been tested, otherwise proceed directly:

Building from cmd.exe command line

If you want to build from the command line, CMake output will show you the proper command to run (which depends on the configured release directory). But this command will produce a Debug build which does not work on Windows and results in a Numpy import error in LabRPS (which is a known issue but hard to fix). You need to specify the --config Release option to force a Release build:

cmake --build E:/release --config Release

Please note that setting CMake variables like CMAKE_BUILD_TYPE does not have any effect, only specifying the --config option as shown above works.

Building with Visual Studio 17 (2022) or newer

Release Build

  1. Start the Visual Studio IDE. This can either be done by pressing the button Open Project in the CMake GUI or by double-clicking on the file LabRPS.sln that you find in your build folder.
  2. In the toolbar of the MSVC IDE assure that you use for the first compilation Release.
  3. There is a window called Solution Explorer. It lists all possible compilation targets. To start a full compilation, right-click on the target ALL_BUILD and then choose Build.

This will now take quite a long time.

To compile a ready-to use LabRPS, compile the target INSTALL, see the section Running and installing LabRPS.

If you don't get any errors you are done. Congratulations! You can exit MSVC or keep it open.

Debug Build

For a debug build it is necessary that the Python is used that is included in the LibPack. To assure this:

  1. Search in the CMake GUI for "Python"
  2. If you see there a path like C:/Program Files/Python38/python.exe, CMake recognized the Python that is installed on your PC and not the one of the LibPack. In this case adapt these different Python settings in CMake to this (assuming the LibPack is in the folder D:\LabRPS-build\LabRPSLibs_1.0.0_x64_VC17):

File:CMake Python settings.png

As prerequisite for the debug build, you need to do this:

  1. Copy the content of the LibPack folder bind to the bin folder of the LabRPS build folder (overwrite the existing files).
  2. Copy the content of the LibPack folder libd to the lib folder of the LabRPS build folder.

Now you can compile:

  1. Start the Visual Studio IDE. This can either be done by pressing the button Open Project in the CMake GUI or by double-clicking on the file LabRPS.sln that you find in your build folder.
  2. In the toolbar of the MSVC IDE assure that you use for the first compilation Debug.
  3. There is a window called Solution Explorer. It lists all possible compilation targets. To start a full compilation, right-click on the target ALL_BUILD and then choose Build in the context menu.

This will now take quite a long time.

If there were no compilation errors, and if the LABRPS_COPY_* options mentioned in the CMake Configuration step above were enabled, you can start the debug build:

  1. Right-click on the target LabRPSMain and then choose Set as Startup Project in the context menu.
  2. Finally click in the toolbar on the button with the green triangle named Local Windows Debugger.

This will start the debug build of LabRPS and you can use the MSVC IDE to debug it.

Command line build

The steps how to compile from the command line depends on the compiler. For MSVC 2022 the steps are:

  1. In Windows start menu go to Visual Studio 2022 → Visual Studio Tools and choose Developer Command Prompt for VS 2022
  2. Change to your build folder.
  3. Execute the command
msbuild ALL_BUILD.vcxproj /p:Configuration=Release

or

msbuild INSTALL.vcxproj /p:Configuration=Release

These steps can also be automaized. Here is for example a solution for MSVC 2022:

  1. Download the script compile-FC.txt.
  2. Rename it to compile-FC.bat
  3. In Windows file explorer Shift+Right-click on your build folder and use from the context menu Command prompt here.
  4. Execute the command
compile-FC install

Instead of calling compile-FC with the option install you can also use debug or release:

debug   - compile LabRPS in debug configuration

release - compile LabRPS in release configuration

install    - compile LabRPS in release configuration and create an install setup

Running and installing LabRPS

There are 2 methods to run the compiled LabRPS:

Method 1: You execute the LabRPS.exe that you find in your build folder in the subfolder bin

Method 2: You build the target INSTALL

Method 2 is the simpler one because it automatically assures that all libraries needed to run the LabRPS.exe are in the correct folder. The LabRPS.exe and the libraries will be output in the folder you specified in the CMake variable CMAKE_INSTALL_PREFIX.

For Method 1 you need to enable the LABRPS_COPY_* options mentioned in the CMake Configuration step above.

Troubleshooting

When running LabRPS you may encounter missing DLLs when using certain workbenches or features of workbenches. The error message in LabRPS's console will not tell you what DLL is missing. To find this out you must use an external tool:

import os
os.system(r"~\DependenciesGui.exe")

Note: Instead of the ~ you must specify the full path to the DependenciesGui.exe on your system.

  • Now drag in the *.pyd file of the workbench with which you get missing DLLs reported.

Updating the build

LabRPS is very actively developed. Therefore its source code changes almost daily. New features are added and bugs are fixed. To benefit from these source code changes, you must rebuild your LabRPS. This is done in two steps:

  1. Updating the source code
  2. Recompilation

Updating the source code

Using a frontend

When using the Git frontend TortoiseGit:

  1. Right-click on your LabRPS source code folder in the Windows file explorer and select Pull in the context menu.
  2. A dialog will appear. Select there what development branch you want to get. master is the main branch. Therefore use this unless you want to compile a special new feature from a branch that has not yet been merged to master. (For more about Git branches, see Git development process.)

Finally click OK.

Using the command line

Open a terminal (command prompt) and switch there to your source directory. Then type:

git pull https://github.com/LabRPS/LabRPS.git master

where master the the name of the main development branch. If you want to get code from another branch, use its name instead of master.

Tools

In order to join the LabRPS development you should compile and install the following tools:

Qt Designer plugin

LabRPS uses Qt as toolkit for its user interface. All dialogs are setup in UI-files that can be edited using the program Qt Designer that is part of any Qt installation and also included in the LibPack. LabRPS has its own set of Qt widgets to provide special features like adding a unit to input fields and to set preferences properties.

Compilation

The plugin cannot be loaded by the Qt Designer if it was compiled using another Qt version than the one your Qt Designer/Qt Creator is based on. Therefore the plugin must be compiled together with LabRPS:

  • In the CMake options (see this section above) enable the option BUILD_DESIGNER_PLUGIN and reconfigure.
  • open MSVC and build the target LabRPS_widgets

As result you will get the plugin file 'LabRPS_widgets.dll in the folder
~\src\Tools\plugins\widget\Release

Installation

To install the plugin, copy the DLL either to:

  • If you use the LibPack: to the folder
    ~\LabRPSLibs_1_0_0_x64_VC2022\plugins\designer
  • If you have a full Qt installation: you can choose between the folder
    C:\Qt\5.15.2\msvc2022_64\plugins\designer
    or
    C:\Qt\5.15.2\msvc2022_64\bin\designer (you must first create the designer subfolder.)
    (adapt the paths to your installation!).

Finally (re)start Qt Designer and check its menu Help → Plugins. If the plugin LabRPS_widgets.dll is listed as being loaded, you can now design and change LabRPS's .ui files. If not, you must compile the DLL by yourself.

If you prefer using Qt Creator instead of Qt Designer, the plugin file must be placed in this folder:
C:\Qt\Qt5.15.2\Tools\QtCreator\bin\plugins\designer
Then (re)start Qt Creator, switch to the mode Design and then check the menu Tools → Form Editor → About Qt Designer Plugins. If the plugin LabRPS_widgets.dll is listed as being loaded, you can now design and change LabRPS's .ui files. If not, you must compile the DLL by yourself.

References

See also


Arrow-left.svg Previous: License