From FlightGear wiki
Jump to: navigation, search

fg-from-scratch is a windows batch script capable of producing a working release version of flightgear and terragear executables.

Building and Running Flightgear

Building and Running any piece of modern software is a complex process. There are literally millions of pieces of information that need to be brought together and processed in just the right way, in just the right order or the whole thing falls apart and the process ends short of your goal with a flurry of cryptic messages or worse, no message at all. Stuff happens. One or more of those millions of pieces of information can be inappropriate, incorrect, incomplete, or missing entirely.

If you're already familiar with modern build processes, you can skip the basics User:Callahanp/Building_and_Running_Flightgear_basics Building and Running Flightgear - The Basics

Improvements Contemplated

This is my personal un-official list. It is not a commitment to do or a request that you do the work necessary to accomplish any of it. I can commit to doing the first item.

  • Visual Studio Debug Build
  • Separate Build and Install Directories for Release and Debug Targets
  • Updated
    • add links to vcpkg, Visual Studio and CMake documentation
    • add current state of the script
    • add a bit of history.. who developed it, why, how it grew over time...
  • Document the internal operations of the fg-from-scratch build script
  • Document any limitations or adaptations imposed by upstream libraries
  • fg-from-scratch Issues List
  • Try a remote linux build with Visual Studio
  • Investigate use of Visual Studio Code instead of the full Visual Studio

Build Issues

Warning Messages:

  • command line warning D9002: ignoring unknown option '/arch:SSE2'

Error Messages:

  • Error MSB6006 "cmd.exe" exited with code -1073741515. embeddedresources C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets 231
  • Error MSB6006 "cmd.exe" exited with code 1. fgfs_autogen C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets 231


Discussion of this topic can take place in the following thread on the flightgear-devel mailing list, on the talk page or elsewhere as needed.

Cmake and Visual Studio


 vcpkg compiles c++ library sources "using the most recent version of Visual Studio that it can find. In C++, it's important that both your application code and any libraries you use are compiled by the same compiler, and compiler version. By using vcpkg, you eliminate or at least greatly reduce the potential for mismatched binaries and the problems they can cause." -- [Microsoft Article on vcpkg]

In theory, fg-from-source depends on the value of the external variable VCPKG_DEFAULT_TRIPLET to determine which version of a library to build. It should be set as X64-windows to build 64 bit libraries. However it does not seem to be referenced in the script itself or in vcpkg-git/scripts/bootstrap.ps1 It is referenced in the vcpkg executable, so go ahead and set it.

fg-from-scratch will clone the vcpkg application into .vcpkg-git and run .bootstrap-vcpkg from that directory if not previously installed.

Subsequent runs will do a git-pull and call the .boostrap-vcpkg script again. this is followed by a vcpkg update and vcpkg-upgrade

Non-vcpkg CMake usage will properly find libraries built with vcpkg if the toolchain file is set. This setting can be seen in fg-from-scratch cmake commands for building OpenSceneGraph, SimGear and FlightGear

cmake ../my/project -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake

At this point you should take a moment to review the vcpkg documentation found in three .md files in




  • Find out if ninja is currently used in fg-from-scratch.cmd
  • if it is include it in research.
  • If not, discuss advantages/disadvantages with the wider flightgear development community.

Per target build and install directories

A technique I've observed in use is to provide separate build and install directories for each target build: release, rel-with-debug, debug.


  • Investigate vcpkg-git, scratch-build and scratch-install to determine where per-target build or install directories are and are not used.


CMakeLists.txt in OpenSceneGraph, Simgear, FlightGear, SimGear

This note is not meant to imply that changes in the named projects Cmake files are or will be needed.

The CMakeLists.txt used by the OpenSceneGraph, Simgear, FlightGear and TerraGear projects are used in automatic build processes and in the case of OSG are separately managed projects. They should be considered out of the scope of changes to fg-from-scratch. Anyone working on fg-from-scratch will have to make do with their current state, adjust to any changes in them, and advocate separately for any proposed changes to them.

Package CMake Compatibility with Built-In CMake Targets

The log of a fg-from-scratch.cmd run includes the following text:

The package openssl is compatible with built-in CMake targets:
   find_package(OpenSSL REQUIRED)
   target_link_libraries(main PRIVATE OpenSSL::SSL OpenSSL::Crypto)

Does this imply that there are other packages which do not satisfy this criteria? If so, which ones are not? What is the impact of a package not being compatible with built in CMake targets?