20,741
edits
m (added category) |
|||
(41 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
{{Main article|Building Flightgear}} | {{Main article|Building Flightgear}} | ||
== Also see == | |||
Please also see [[Superbuild]]. | |||
== Build Environment & Dependencies == | == Build Environment & Dependencies == | ||
===Linux / Unix === | ===Linux / Unix === | ||
{{Note|as of 12/2017, people may have to build using at least OSG 3.4 due to some compilation issues -for details, refer to [[Howto:Building FlightGear without HiDPI support]]}} | |||
* Install Boost, OpenAL, ALUT, PLIB and other OpenSceneGraphDependencies (eg, libpng). | * Install Boost, OpenAL, ALUT, PLIB and other OpenSceneGraphDependencies (eg, libpng). | ||
* [[Fedora 16 Package List]] | * [[Fedora 16 Package List]] | ||
* [[Ubuntu 12.04 Package List and Build Hints]] | |||
* Qt5 for [[Integrated Qt5 Launcher]] (optional) | |||
* Get the OpenSceneGraph sources, either from subversion or a zip | * Get the OpenSceneGraph sources, either from subversion or a zip | ||
Line 13: | Line 16: | ||
* '''NOTE''': On Debian AMD64 (or not 32-bit) systems (maybe including Ubuntu) there is currently a packaging error which leads to false detection of OpenAL. Until it got repaired, you have 2 options left: | * '''NOTE''': On Debian AMD64 (or not 32-bit) systems (maybe including Ubuntu) there is currently a packaging error which leads to false detection of OpenAL. Until it got repaired, you have 2 options left: | ||
1. Goto /usr/share/cmake-2.8/Modules/ (it is the right patch on my Debian system) and expand the search path with lib/x86_64-linux-gnu/: | 1. Goto /usr/share/cmake-2.8/Modules/ (it is the right patch on my Debian system) and expand the search path with lib/x86_64-linux-gnu/: | ||
< | <syntaxhighlight lang="sh">sudo su # to become root | ||
cd /usr/share/cmake-2.8/Modules/ # again, use the proper path of your system | cd /usr/share/cmake-2.8/Modules/ # again, use the proper path of your system | ||
$EDITOR FindOpenAL.cmake | $EDITOR FindOpenAL.cmake | ||
Line 21: | Line 24: | ||
# Save it | # Save it | ||
# Quit your editor | # Quit your editor | ||
exit # to leave root</ | exit # to leave root</syntaxhighlight> | ||
2. (As I did) Set a symbolic link so cmake can find it: | 2. (As I did) Set a symbolic link so cmake can find it: | ||
< | <syntaxhighlight lang="sh">sudo su # again, become root | ||
cd /usr/lib/ | cd /usr/lib/ | ||
ln -s x86_64-linux-gnu/* . # ignore that error for pkconfig for now | ln -s x86_64-linux-gnu/* . # ignore that error for pkconfig for now | ||
cd pkconfig/ | cd pkconfig/ | ||
ln -s ../x86_64-linux-gnu/pkgconfig/* .</ | ln -s ../x86_64-linux-gnu/pkgconfig/* .</syntaxhighlight> | ||
* Both steps have advantages and disadvantages, e.g. when it comes to updates, so you might need to repeat your desired path and fix your symbolic links by removing them first (!) and then re-create them. A big "thanks" to James for giving me the hints. :) | * Both steps have advantages and disadvantages, e.g. when it comes to updates, so you might need to repeat your desired path and fix your symbolic links by removing them first (!) and then re-create them. A big "thanks" to James for giving me the hints. :) | ||
* If you have OSG/PLIB on different directories than the usual, use environmental variables OSG_DIR/PLIBDIR, e.g. addd to ~/.bashrc: | * If you have OSG/PLIB on different directories than the usual, use environmental variables OSG_DIR/PLIBDIR, e.g. addd to ~/.bashrc: | ||
< | <syntaxhighlight lang="sh"># OSG/PLIB special directory | ||
export OSG_DIR=/opt/my-osg-path | export OSG_DIR=/opt/my-osg-path | ||
export PLIBDIR=/opt/my-plib-path</ | export PLIBDIR=/opt/my-plib-path</syntaxhighlight> | ||
Note: In order to set the CFLAGS/CXXFLAGS variables for make/gcc, simply configure cmake and define | |||
CMAKE_C_FLAGS and CMAKE_CXX__FLAGS. | |||
For example, to enable gprof: | |||
<syntaxhighlight lang="sh"> | |||
cmake ../flightgear -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_C_FLAGS=-pg -DCMAKE_CXX_FLAGS=-pg | |||
</syntaxhighlight> | |||
===Mac=== | ===Mac=== | ||
* Install Xcode (from the App Store) | * Install Xcode (from the App Store) | ||
* | * Install Boost from MacPorts (or directly from source) | ||
* Install the Subversion client libraries and PLIB. These are included in the 'Mac 3rd-party dependencies' zip file. PLIB is also available through MacPorts, and Subversion is available by default on Snow Leopard (10.6) and Lion (10.7) but NOT on Mountain Lion (10.8) | |||
* Install OpenSceneGraph. | |||
The easiest solution is to grab the 3rd-party dependencies build from Jenkins: {{Build link|path=job/Mac-3rdparty-deps/lastSuccessfulBuild/artifact/*zip*/archive.zip}}. This will give you a 'dist' directory containing PLIB, Subversion and OpenSceneGraph correctly configured. When configured SimGear and FlightGear, simply use this dist directory as CMAKE_INSTALL_PREFIX, and all the dependencies should be found with no other steps. | |||
{{#tag:syntaxhighlight| | |||
# make a top-level directory to contain everything | |||
mkdir FGFS | |||
cd FGFS | |||
# move the downloaded 'dist' dir from the zip inside FGFS | |||
mv <dist dir from Jenkins> . | |||
# clone from Git | |||
{{simgear clone}} | |||
{{flightgear clone}} | |||
mkdir sgbuild | |||
cd sgbuild | |||
cmake ../simgear -DCMAKE_INSTALL_PREFIX=$PWD/../dist | |||
make; make install | |||
cd .. | |||
mkdir fgbuild | |||
cd fgbuild | |||
cmake ../flightgear -DCMAKE_INSTALL_PREFIX=$PWD/../dist | |||
make; make install | |||
| lang = "sh" | |||
}} | |||
Note this demonstrates start from a clean setup - after the initial build it's sufficient to simply 'git pull' in the clones repositories, then execute a 'make; make install' in the build directories. You can of course have multiple build directories with different configurations, as described in more detail below. | |||
===Windows=== | ===Windows=== | ||
Line 54: | Line 95: | ||
/home/curt/projects/fgbuild. Change into the new directory, and run | /home/curt/projects/fgbuild. Change into the new directory, and run | ||
<syntaxhighlight lang="sh"> | |||
cmake ../flightgear | |||
</syntaxhighlight> | |||
To generate standard Unix Makefiles in fgbuild. | To generate standard Unix Makefiles in fgbuild. | ||
Line 62: | Line 105: | ||
Probably you want to specify an install prefix: | Probably you want to specify an install prefix: | ||
<syntaxhighlight lang="sh"> | |||
cmake -DCMAKE_INSTALL_PREFIX=/usr ../flightgear | |||
</syntaxhighlight> | |||
Note the install prefix is automatically searched for required libraries | Note the install prefix is automatically searched for required libraries | ||
Line 71: | Line 116: | ||
you can specify one or more via CMAKE_PREFIX_PATH: | you can specify one or more via CMAKE_PREFIX_PATH: | ||
<syntaxhighlight lang="sh"> | |||
cmake -DCMAKE_PREFIX_PATH="/opt/local;/opt/fgfs" ../flightgear | |||
</syntaxhighlight> | |||
(note the use of semi-colons to specify multiple prefix paths) | (note the use of semi-colons to specify multiple prefix paths) | ||
Line 81: | Line 128: | ||
described above will work, but specifying an INSTALL_PREFIX or PREFIX_PATH is | described above will work, but specifying an INSTALL_PREFIX or PREFIX_PATH is | ||
usually simpler. | usually simpler. | ||
== Debug Builds == | |||
By default, we select a release build. To create a debug build, use | By default, we select a release build. To create a debug build, use | ||
<syntaxhighlight lang="sh"> | |||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../flightgear | |||
(or MinSizeRel, or | </syntaxhighlight> | ||
(or MinSizeRel, or Debug) | |||
Debug builds will automatically use corresponding debug builds of required | Debug builds will automatically use corresponding debug builds of required libraries, if they are available. For example you can install debug builds of | ||
libraries, if they are available. For example you can install debug builds of | |||
SimGear and OpenSceneGraph, and a debug FlightGear build will use them. | SimGear and OpenSceneGraph, and a debug FlightGear build will use them. | ||
(Debug builds of libraries have the 'd' suffix by default - Release builds | (Debug builds of libraries have the 'd' suffix by default - Release builds have no additional suffix) | ||
have no additional suffix) | |||
'''Important: You should keep in mind that debug builds are usually not optimized at all. Thus, it is very likely that a debug binary will perform worse (framerate/performance-wise) than a release build. Many people have reported getting just frame rates of about 30 fps when using a debug binary!''' | |||
Note most IDE projects (eg Xcode and Visual Studio) support building all the build types from the same project, so you can omit the CMAKE_BUILD_TYPE option when running cmake, and simply pick the build configuration as normal in the IDE. | |||
== Profiling == | |||
You can also build with optional profiling support by using '''-DENABLE_PROFILE=ON''', for details see: [[Built-in Profiler]]. | |||
== Multiple build directories == | |||
build | |||
It's common to have several build directories with different build | It's common to have several build directories with different build configurations (see [http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg39400.html] for more info), eg | ||
configurations, eg | |||
/home/curt/projects/flightgear (the git clone) | /home/curt/projects/flightgear (the git clone) | ||
Line 107: | Line 160: | ||
/home/curt/projects/fgrelease | /home/curt/projects/fgrelease | ||
/home/curt/projects/fg-with-svn-osg | /home/curt/projects/fg-with-svn-osg | ||
== Optional Features == | |||
To set an optional feature, do | To set an optional feature, do | ||
<syntaxhighlight lang="sh"> | |||
cmake -DFEATURE_NAME=ON ../flightgear | |||
</syntaxhighlight> | |||
(or 'OFF' to disable ) | (or 'OFF' to disable) | ||
To see the variables that can be configured / are currently defined, you can | To see the variables that can be configured / are currently defined, you can | ||
run one of the GUI front ends, or the following command: | run one of the GUI front ends, or the following command: | ||
<syntaxhighlight lang="sh"> | |||
cmake -L ../flighgear | |||
</syntaxhighlight> | |||
Add 'A' to see all the options (including advanced options), or 'H' to see | Add 'A' to see all the options (including advanced options), or 'H' to see | ||
the help for each option (similar to running configure --help under autoconf): | the help for each option (similar to running configure --help under autoconf): | ||
<syntaxhighlight lang="sh"> | |||
cmake -LH ../flightgear | |||
</syntaxhighlight> | |||
== Build Targets == | == Build Targets == | ||
Line 130: | Line 191: | ||
but there is *no* 'make distclean' target. The equivalent is to completely | but there is *no* 'make distclean' target. The equivalent is to completely | ||
remove your build directory, and start with a fresh one. | remove your build directory, and start with a fresh one. | ||
== SimGear Build Options == | |||
{{Out of date}} | |||
current CPU's at least support SSE3 so that is enabled by default now, Enabling AVX adds another speedup for double precision floating point calculations which is pretty much all of the FlightGear math.<ref>{{cite web | |||
|url = https://forum.flightgear.org/viewtopic.php?p=302451#p302451 | |||
|title = <nowiki> Re: Simgear compilation failure </nowiki> | |||
|author = <nowiki> erik </nowiki> | |||
|date = Jan 1st, 2017 | |||
|added = Jan 1st, 2017 | |||
|script_version = 0.40 | |||
}}</ref> | |||
Some of the more common SimGear build options include | |||
* '''-DENABLE_PROFILE=ON''' (enable support for the [[Built-in Profiler]]) | |||
* '''-ENABLE_SIMD=ON''' [[SIMD Support]] | |||
* '''-ENABLE_DNS=ON''' uDNS support | |||
* '''-DENABLE_TESTS=OFF''' (disable unit tests) | |||
* '''-DSIMGEAR_HEADLESS=ON''' (enables a headless build, i.e. without OSG and other graphics stuff) | |||
* '''-DENABLE_LIBSVN=OFF''' (disables subversion support, i.e. scenery fetching, to be depreciated, see [http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg40191.html] ) | |||
* '''-DENABLE_SOUND=OFF''' (disables OpenAL/sound support) | |||
* '''-DCMAKE_INSTALL_PREFIX=$HOME''' (installs everything into $HOME, instead of system-wide) | |||
* '''-DENABLE_RTI=ON''' (enable [[HLA]] support) | |||
* '''-DJPEG_FACTORY=ON''' (enable jpeg support) | |||
* '''-DENABLE_FLITE=ON''' (enable FLITE TTS-based ATIS) [http://sourceforge.net/p/flightgear/mailman/message/32265565] [{{flightgear url|commit=cadb77b18d13bb0d45672ac607801bda222454e9}}] | |||
* '''-ENABLE_GDAL=ON''' (GDAL/OGR) 02/2017 <ref>https://sourceforge.net/p/flightgear/simgear/ci/dad30b0cc212e6ecd4b332cbc4f1335349f89188</ref> | |||
* {{CMake Build Option|option=ENABLE_OPENMP|default=ON|version=02/2017 <ref>https://sourceforge.net/p/flightgear/simgear/ci/dad30b0cc212e6ecd4b332cbc4f1335349f89188</ref>|description=OpenMP support}} | |||
== LTO == | |||
Erik has tried to compile Simgear and FlightGear using 'gcc -flto' to see if he could squeee just a bit more performance out of the code. | |||
To be able to do so he's run cmake for both Simgear and FlightGear as follows: | |||
<syntaxhighlight lang="sh"> | |||
cmake -DCMAKE_AR=/usr/bin/gcc-ar \ | |||
-DCMAKE_RANLIB=/usr/bin/gcc-ranlib \ | |||
-DCMAKE_NM=/usr/bin/gcc-nm \ | |||
-DSIMGEAR_SHARED=1 \ | |||
-DCMAKE_BUILD_TYPE=Release \ | |||
-DCMAKE_CXX_FLAGS:STRING="-Os march=native -mtune=native -msse3 -mfpmath=sse -flto" | |||
</syntaxhighlight> | |||
After applying one patch to SimGear he got it compiling. | |||
The resulting binary is almost exactly 5Mb smaller: | |||
* 14390984 fgfs-lto | |||
* 19354528 fgfs | |||
It did not alter the frame-rates much for him (he's got quite a decent videocard now with the GeForce GTX 750) but Erik did have the distinct feeling there were way less small-pauses/frame-rate glitches when compared to the regular build. The overall feeling was much smoother.<ref>{{cite web | |||
|url = https://sourceforge.net/p/flightgear/mailman/message/35478384/ | |||
|title = <nowiki> [Flightgear-devel] Link Time Optimization </nowiki> | |||
|author = <nowiki> Erik Hofman </nowiki> | |||
|date = Nov 8th, 2016 | |||
|added = Nov 8th, 2016 | |||
|script_version = 0.40 | |||
}}</ref> | |||
== XCode == | |||
On Mac, '-G Xcode' will generate nice XCode projects. You can then build in the IDE or using xcodebuild. Ensure you have a recently CMake build, since Xcode support has improved in recent versions (2.8.9 at time of writing). CMake generates an 'install' target which is needed for SimGear, but FlightGear can be run and debugged directly (no install required) - simply set your DYLD_LIBRARY_PATH in the target options, to include your 'dist' directory. | |||
== Troubleshooting == | |||
If you get the error "Oops, you have installed SimGear includes, however test compiling failed. Try removing 'CMakeCache.txt' and reconfigure with 'cmake'." when trying to run cmake for flightgear it could be that you have an old SimGear version installed from your package manager. | |||
If you get that error or anything strange even though all is apparently fine with matching simgear and flightgear versions you should check how your filesystem is mounted, because if it is an extra partition it could be that is mounted with the "noexec" flag and cmake cannot work in that conditions. | |||
{{Building}} | {{Building}} |