THIS IS A WORK IN PROGRESS. Nothing is included in the main tree yet.
JSBSIM is an open source flight dynamics model (FDM) written in C++.
It is free software distributed according to the terms of the GPL 3.0.
JSBSIM use autotools under unices and visual project under Windows. The maintenance of both system can be made easier thanks to CMake.
Since initial writting of this page (december 2012), CMake support have been introduced in JSBSim. The patches previously presented on this page are now obsolete.
JSBSIM doesn't allow (yet) to write custom code that could be dynamically loaded at runtime. For instance, i would like to write my own output model without recompiling JSBSIM executable. Moreover, it could allow the projects that use JSBSIM (like flighgear) to maintain their interface easier (or at least outside of the jsbsim sources).
This is an experimental feature which is currently submitted for inclusion in JSBSIM. Comments for improvement are welcome.
This work is mainly developed and tested under Linux, but some basic tests have been done under Windows (MinGW).
For licencing problems, we can refer to the GPL FAQ.
The following table summarize the supported features.
Feature | Autotools options(1) | CMake Options(2) | Linux | Mac OSX | Windows | ||
---|---|---|---|---|---|---|---|
GCC | GCC | Mingw | MSVC | Cygwin | |||
default options (legacy static code) | Yes | Yes | Yes | Yes | Yes | ||
Shared JSBSim library | --enable-libraries | -DBUILD_SHARED_LIBS=TRUE | Yes | Yes | Yes | No | No |
Plugins feature | Not supported | -DJSBSIM_ENABLE_PLUGINS=TRUE | Yes | Yes(3) | Yes(3) | No(4) | No(4) |
(1) : see build with autotools.
(2) : see build with cmake.
(3) : only works with shared JSBSim.
(4) : will probably work when the plugins with static lib will work.
Under Windows, you can get cmake from here. Under Linux, a package should exists for your distribution. The tests have been done with cmake >= 2.8.8.
Under Windows, we recommend to use MINGW compiler to try the plugin feature. However, you could also try alternative solutions.
Under Linux, you should already have a toolchain installed (tested with GCC, no clang).
You can get my branch with plugin feature on gitorious.
git clone https://gitorious.org/jsbsim/polch-jsbsim.git jsbsim
cd jsbsim
The legacy JSBSIM build system is based on autotools. Only building in source tree is supported (TBC). Moreover, the plugin feature isn't supported for this configuration system yet.
cd jsbsim
./autogen.sh --enable-libraries
make
make install DESTDIR=${PWD}/_install
You are ready to run sample code.
We have 3 build options :
The usage of cmake consist in :
The following examples use the CLI interface, but cmake also provide a GUI interface. One example of usage will be given.
The ".." (double dot) means parent directory, it shouldn't be omitted.
Run the following commands :
mkdir build_linux
cd build_linux
cmake -DBUILD_SHARED_LIBS=TRUE -DJSBSIM_ENABLE_PLUGINS=TRUE ..
make
make check-local
make install DESTDIR=${PWD}/_install
To uninstall you can call :
xargs rm < install_manifest.txt
Build the customIO plugin example, from the top of the JSBSim source directory :
make -C exemples/plugins JSBSIM_PREFIX=${PWD}/_install/usr/local
You are ready to run sample code.
See Linux, that is the same procedure.
You are ready to run sample code.
Tested with the MinGW bundled in Code::Blocks 13.12.
mkdir build_mingw
cd build_mingw
"c:\Program Files\CodeBlocks\MinGW\mingwvars.bat"
cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=TRUE -DJSBSIM_ENABLE_PLUGINS=TRUE -DCMAKE_INSTALL_PREFIX="c:/JSBSim" ..
mingw32-make
mingw32-make install DESTDIR=%CD%\_install
Instead of cmake -G "MinGW Makefiles" ..
, you can call cmake -G "CodeBlocks - MinGW Makefiles" ..
. It will generate a .cbp
project file that can be opened in Code::Blocks.
Build the customIO plugin example, from the top of the JSBSim source directory :
mingw32-make -C exemples/plugins JSBSIM_PREFIX=%CD%\_install\JSBSim RM=del MOD_SUFFIX=.dll
You are ready to run sample code.
WARNING : options "-DBUILD_SHARED_LIBS=TRUE -DJSBSIM_ENABLE_PLUGINS=TRUE
" won't work.
Run the following commands :
mkdir build_cygwin
cd build_cygwin
cmake -G "Unix Makefiles"..
make
make install DESTDIR=${PWD}/_install
To uninstall you can call :
xargs rm < install_manifest.txt
You are ready to run sample code.
WARNING : options "-DBUILD_SHARED_LIBS=TRUE -DJSBSIM_ENABLE_PLUGINS=TRUE
" not tested.
Tested with MSVC 2012 express.
mkdir build_msvc_nmake
cd build_msvc_nmake
"c:\Program Files\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"
cmake -G "NMake Makefiles" ..
nmake
nmake install DESTDIR=%CD%\_install
You are ready to run sample code.
WARNING : options "-DBUILD_SHARED_LIBS=TRUE -DJSBSIM_ENABLE_PLUGINS=TRUE
" not tested.
Tested with MSVC 2010 express SP1.
mkdir build_msvc_10
cd build_msvc_10
"c:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
cmake -G "Visual Studio 10" ..
msbuild jsbsim.sln
Tested with MSVC 2012 express.
mkdir build_msvc_11
cd build_msvc_11
"c:\Program Files\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"
cmake -G "Visual Studio 11" ..
msbuild jsbsim.sln
You can also open jsbsim.sln with visual studio IDE.
Note : I'm not able to launch the installation from CLI. The code hereunder doesn't work. But you can build the INSTALL project in the Visual Studio IDE and it works (if you have admin privileges).
msbuild /target:INSTALL jsbsim.sln
cmake --build . --target install --config Debug
You can run the sample code from the build tree.
You can set the JSBSIM_DEBUG env var to have more traces.
Set the path to the shared library, LD_LIBRARY_PATH, environment variable, for the JSBSIm library and for the plugin library, from the top of the JSBSim source directory :
export LD_LIBRARY_PATH=${PWD}/exemples/plugins:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${PWD}/_install/usr/local/lib:$LD_LIBRARY_PATH
export PATH=${PWD}/_install/usr/local/bin:$PATH
Run the JSBSim program :
JSBSim --root=${PWD}/exemples/plugins --aircraft=ball --initfile=reset00_v2 --end-time=100
Set the path to the shared library, DYLD_LIBRARY_PATH, environment variable, for the JSBSIm library and for the plugin library, from the top of the JSBSim source directory :
export DYLD_LIBRARY_PATH=${PWD}/exemples/plugins:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=${PWD}/_install/usr/local/lib:$DYLD_LIBRARY_PATH
export PATH=${PWD}/_install/usr/local/bin:$PATH
Run the JSBSim program :
JSBSim --root=${PWD}/exemples/plugins --aircraft=ball --initfile=reset00_v2 --end-time=100
Set the path to the shared library, PATH, environment variable, for the JSBSIm library and for the plugin library, from the top of the JSBSim source directory :
set PATH=%CD%\exemples\plugins;%PATH%
set PATH=%CD%\_install\JSBSim\lib;%PATH%
set PATH=%CD%\_install\JSBSim\bin;%PATH%
Run the JSBSim program :
JSBSim --root=${PWD}/exemples/plugins --aircraft=ball --initfile=reset00_v2 --end-time=100
Set the path to the shared library, PATH, environment variable, for the JSBSIm library and for the plugin library, from the top of the JSBSim source directory :
export LD_LIBRARY_PATH=${PWD}/exemples/plugins:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${PWD}/_install/Program\ Files/jsbsim/lib:$LD_LIBRARY_PATH
export PATH=${PWD}/_install/Program\ Files/jsbsim/bin:$PATH
Run the JSBSim program :
JSBSim --root=${PWD}/exemples/plugins --aircraft=ball --initfile=reset00_v2 --end-time=100
Plugins (or modules) can have any name since the library containing the IO models will be named in the XML file with the library
attribute.
Depending on the platform, modules have specific naming convention (they can be prefixed with lib
under unices, they can end with so
, dll
, ...). You will only provide the common part of the name of the library.
A library can contains one or more IO models. The only interface that JSBSim needs is a factory for your model with the following signature :
extern "C"
JSBSim::FGModel * new_Namespace_Model(JSBSim::FGFDMExec* fdmex);
For instance, the following code will look for a module named "CustomIO".
<output library="CustomIO" type="CustomOutput" name="stdout" rate="1">
<position> ON </position>
</output>
<input library="CustomIO" type="CustomInput" name="stdin" rate="1"/>
This module should provide an outpout model factory :
JSBSim::FGModel * new_CustomIO_CustomOutput(JSBSim::FGFDMExec* fdmex)
and an input model factory :
JSBSim::FGModel * new_CustomIO_CustomInput(JSBSim::FGFDMExec* fdmex)
Sample code is available in the jsbsim source tree (examples/plugins). The compilion is done thanks to a simple makefile.
We sometimes use JSBSim as an extarnal library linked to our programs. In such a case, we could avoid making separate shared modules and simply provides our custom IO models in our main code base. JSBSim will look for the model factory in the current executable before searching in external libraries.
This is a note for personal use in order to test the Bertrand's code.
Build the code :
cd jsbsim
./autogen.sh --enable-libraries
make
make install DESTDIR=${PWD}/_install
Run the plugin test code :
export LD_LIBRARY_PATH=${PWD}/_install/usr/local/lib/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${PWD}/_install/usr/local/lib/JSBSim/:$LD_LIBRARY_PATH
./src/.libs/JSBSim --root=${PWD} --aircraft=ball --initfile=reset00 --end-time=100