Building using CMake - Windows: Difference between revisions

Jump to navigation Jump to search
Update MSVC and fix minor typos
(Update MSVC and fix minor typos)
Line 1: Line 1:
{{Main article|Building Flightgear}}
{{Main article|Building FlightGear}}
This article is intended to give an overview of building FlightGear on modern Windows systems. It was created using Windows 10 and VS 2019. It ought to be transferrable to earlier versions of the Windows OS and software.
This article is intended to give an overview of '''building FlightGear on modern Windows systems'''. It was created using Windows 10 and VS 2022. It ought to be transferable to earlier versions of the Windows OS and software.


As FlightGear is now 64-bit only, the guide only describes building on a 64-bit system.
As FlightGear is now 64-bit only, the guide only describes building on a 64-bit system.
Line 6: Line 6:
== Required software ==
== Required software ==
* [https://cmake.org/download/ CMake for Windows]. Download and install the Windows Win64-x64 Installer.
* [https://cmake.org/download/ CMake for Windows]. Download and install the Windows Win64-x64 Installer.
* [https://visualstudio.microsoft.com/downloads/ Microsoft Visual Studio 2022] (MSVC). The Community version is free. There is no need for the premium versions; none of their features are required to build FlightGear. The C++ compiler will not be installed by default. You either choose this component during installation or after installation by starting MSVC and trying to create a new C++ project. The one to download is "Desktop Development with C++". Make sure to have the last version of the Windows SDK and C++ Compiler checked. As of 10/13/2023, the latest version of the compiler is "MSVC 142 - VS 2019 C++ x64/86 build tools (v14.29)".
* [https://visualstudio.microsoft.com/downloads/ Microsoft Visual Studio 2022] (MSVC). The Community version is free. There is no need for the premium versions; none of their features are required to build FlightGear. The C++ compiler will not be installed by default. You either choose this component during installation or after installation by starting MSVC and trying to create a new C++ project. The one to download is "Desktop Development with C++". Make sure to have the latest version of the Windows SDK for your Windows version and the C++ Compiler checked. As of 12/19/2023, the latest version of the compiler is "MSVC v143 - VS 2022 C++ x64/86 build tools".
* [https://www.qt.io/download-open-source/ Qt5] for the [[Integrated Qt5 Launcher]]. Download the online installer, and choose the version matching your toolchain of Visual Studio e.g. "Qt 5.15.2 --> MSVC 2019 64 bit". Any version past 5.9 will be fine; latest 5.x recommended. Leave the default Developer and Designer Tools selection - these are needed for coding and compiling.
* [https://www.qt.io/download-open-source/ Qt5] for the [[Integrated Qt5 Launcher]]. Download the online installer, and choose the version matching your toolchain of Visual Studio e.g. "Qt 5.15.2 --> MSVC 2019 64-bit". Any version past 5.9 will be fine; latest 5.x recommended. Leave the default Developer and Designer Tools selection - these are needed for coding and compiling.
* [https://git-scm.com/download/win Git] to keep your build up to date. It also simplifies downloads of components. Optional, but can't recommend it enough!
* [https://git-scm.com/download/win Git] to keep your build up to date. It also simplifies downloads of components. Optional, but can't recommend it enough!


Line 119: Line 119:
3. Ensure your toolchain version matches, e.g. "Visual Studio 16 2019" for MSVC 2019 or "Visual Studio 15 2017" for MSVC 2017.
3. Ensure your toolchain version matches, e.g. "Visual Studio 16 2019" for MSVC 2019 or "Visual Studio 15 2017" for MSVC 2017.


4. Set ROOT_DIR to the FlightgearBuild folder you created (the above directory structure)
4. Set ROOT_DIR to the FlightGearBuild folder you created (the above directory structure)


==== Post-compilation: Launching FlightGear ====
==== Post-compilation: Launching FlightGear ====
Line 132: Line 132:
# The first time you'll have to choose where FGDATA is -- to do this, select the 'fgdata' directory you cloned at the start.
# The first time you'll have to choose where FGDATA is -- to do this, select the 'fgdata' directory you cloned at the start.


Therafter, simply press the green arrow directly each time you want to start. If there are any local changes, it will recompile; alternatively it will start up directly. It will take a little longer to start as it loads symbols; however you also have the benefit that any segfaults will be caught allowing you to report them!
Thereafter, simply press the green arrow directly each time you want to start. If there are any local changes, it will recompile; alternatively it will start up directly. It will take a little longer to start as it loads symbols; however you also have the benefit that any segfaults will be caught allowing you to report them!


'''As a standard .exe:'''
'''As a standard .exe:'''
NB these instructions overall are intended for setting up for development; there's a slightly more convoluted process for setting up for just plain flying (e.g. taking advantage of new features for aircraft development).
NB these instructions overall are intended for setting up for development; there's a slightly more convoluted process for setting up for just plain flying (e.g. taking advantage of new features for aircraft development).


Essentially, Visual Studio doesn't copy in the DLLs into the /bin/ folder. It's also not ideal to manually copy in the DLLS as it can cause all sorts of issues. However, without the DLLs FlightGear won't work; therefore, you need to set the PATH so it knows where to look for them.
Essentially, Visual Studio doesn't copy in the DLLs into the /bin/ folder. It's also not ideal to manually copy in the DLLs as it can cause all sorts of issues. However, without the DLLs FlightGear won't work; therefore, you need to set the PATH so it knows where to look for them.
This launch script should work, put into your /install/bin/ folder:
This launch script should work, put into your /install/bin/ folder:
{{collapsible script
{{collapsible script
Line 181: Line 181:


=== Changing the Configuration ===
=== Changing the Configuration ===
When the Simgear/FlightGear version numbers change, or you change configuration options (e.g. toggling Compositor, changing OSG versions, changing QT versions) you do have to re-configure in CMake. To do this, it's usually safest to delete the simgear-build and flightgear-build folders and re-run the build.bat script, to ensure the build is clean. There is no need to delete osg-build unless changing OSG version.
When the SimGear/FlightGear version numbers change, or you change configuration options (e.g. toggling Compositor, changing OSG versions, changing Qt versions) you do have to re-configure in CMake. To do this, it's usually safest to delete the simgear-build and flightgear-build folders and re-run the build.bat script, to ensure the build is clean. There is no need to delete osg-build unless changing OSG version.


In case of problems, most of the time deleting the simgear-build and flightgear-build folders and re-running the build.bat script will be sufficient.
In case of problems, most of the time deleting the simgear-build and flightgear-build folders and re-running the build.bat script will be sufficient.

Navigation menu