blob: 253ebe3e355004f9845200dbcf12aa1684d9ae4d [file] [log] [blame]
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Building Prerequisites &mdash; OpenPASS Documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/tabs.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" />
<link rel="shortcut icon" href="../../../_static/openPASS.ico"/>
<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/jquery.js"></script>
<script src="../../../_static/underscore.js"></script>
<script src="../../../_static/doctools.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
<link rel="next" title="Cmake Build Environment" href="40_cmake.html" />
<link rel="prev" title="Prerequisites" href="20_prerequisites.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../index.html" class="icon icon-home"> openPASS
<img src="../../../_static/openPASS.png" class="logo" alt="Logo"/>
</a>
<div class="version">
9999.9999.9999
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Installation Guides</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../10_gui_installation_guide.html">GUI Installation Guide</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../20_sim_installation_guide.html">Simulation Installation Guide</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../meta/sphinx.html">Sphinx</a></li>
<li class="toctree-l2"><a class="reference internal" href="10_quickstart.html">Quick Start</a></li>
<li class="toctree-l2"><a class="reference internal" href="20_prerequisites.html">Prerequisites</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Building Prerequisites</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#referencing-prerequisites">Referencing Prerequisites</a></li>
<li class="toctree-l3"><a class="reference internal" href="#building-osi">Building OSI</a></li>
<li class="toctree-l3"><a class="reference internal" href="#building-protobuf">Building Protobuf</a></li>
<li class="toctree-l3"><a class="reference internal" href="#building-fmil">Building FMIL</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="40_cmake.html">Cmake Build Environment</a></li>
<li class="toctree-l2"><a class="reference internal" href="50_windows.html">Building under Windows</a></li>
<li class="toctree-l2"><a class="reference internal" href="60_linux.html">Building under Linux</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ides/10_vscode.html">Working with VSCode</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ides/20_qt_creator.html">Working with Qt Creator</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../21_pcm_installation_guide.html">PCM Installation Guide</a></li>
</ul>
<p class="caption"><span class="caption-text">User Guides</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../user_guide/10_gui_user_guide.html">GUI User Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../user_guide/20_sim_user_guide.html">Simulation User Guide</a></li>
</ul>
<p class="caption"><span class="caption-text">Advanced topics</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../advanced_topics/10_documentation.html">Documentation Concept</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../advanced_topics/20_simulator_advanced.html">Simulator</a></li>
</ul>
<p class="caption"><span class="caption-text">Other Information</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../license.html">License</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">openPASS</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../../20_sim_installation_guide.html">Simulation Installation Guide</a> &raquo;</li>
<li>Building Prerequisites</li>
<li class="wy-breadcrumbs-aside">
<a href="../../../_sources/installation_guide/sim_installation_guide/installation/30_build_prerequisites.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="building-prerequisites">
<h1>Building Prerequisites<a class="headerlink" href="#building-prerequisites" title="Permalink to this headline"></a></h1>
<p>This section describes custom building of prerequisites of <strong>openPASS</strong>.</p>
<p>To keep this guide as slim as possible, it only describes the <strong>Windows perspective</strong>.
In general, this should work for Linux as well by adjusting paths and the <code class="docutils literal notranslate"><span class="pre">make</span></code> command accordingly.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you are unfamiliar to <code class="docutils literal notranslate"><span class="pre">Cmake</span></code> or working within a <code class="docutils literal notranslate"><span class="pre">MinGW</span> <span class="pre">64-bit</span></code> shell, Section <a class="reference internal" href="40_cmake.html#cmake"><span class="std std-ref">Cmake Build Environment</span></a> and <a class="reference internal" href="50_windows.html#msys2"><span class="std std-ref">MSYS2</span></a> might give you a short introduction on these topics in the scope of Building OpenPASS itself.</p>
</div>
<div class="section" id="referencing-prerequisites">
<span id="ref-prerequisites"></span><h2>Referencing Prerequisites<a class="headerlink" href="#referencing-prerequisites" title="Permalink to this headline"></a></h2>
<p>With the migration from qmake to cmake, all prerequisite are independent of each other and simply can be refereced by using the right <a class="reference internal" href="40_cmake.html#cmake-prefix-path"><span class="std std-ref">CMAKE_PREFIX_PATH</span></a>.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The following information is <strong>DEPRECATED</strong> and only needed if a <code class="docutils literal notranslate"><span class="pre">qmake</span></code> build shall be invoked.</p>
</div>
<p>Historically, <strong>openPASS</strong> (Open Source) uses a <strong>single entry-point</strong> for libraries and headers, so all prerequisites must to be located within a common folder structure.
If <code class="docutils literal notranslate"><span class="pre">qmake</span></code> needs to be invoked, and more than one prerequisite is customized, <strong>a manual step</strong> is necessary to establish this structure.</p>
<p>Example:</p>
<ol class="arabic">
<li><p>Build prerequisite_1</p></li>
<li><p>Build prerequisite_2</p></li>
<li><p>Copy libraries of both prerequisites into e.g. <code class="docutils literal notranslate"><span class="pre">C:\OpenPASS\thirdParty\lib</span></code></p></li>
<li><p>Copy common headers into e.g. <code class="docutils literal notranslate"><span class="pre">C:\OpenPASS\thirdParty\include</span></code></p></li>
<li><p>Reference the entry points by adding the following arguments to the qmake command</p>
<div class="highlight-batch notranslate"><div class="highlight"><pre><span></span>EXTRA_INCLUDE_PATH=c:\OpenPASS\thirdParty\include
EXTRA_LIB_PATH=c:\OpenPASS\thirdParty\lib
</pre></div>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Make sure that there is no linebreak between the two arguments.
Qmake cannot handle this, but does not complain.</p>
</div>
</li>
</ol>
</div>
<div class="section" id="building-osi">
<span id="id1"></span><h2>Building OSI<a class="headerlink" href="#building-osi" title="Permalink to this headline"></a></h2>
<p>As teased in <a class="reference internal" href="20_prerequisites.html#prerequisites"><span class="std std-ref">Prerequisites</span></a>, the core component <code class="docutils literal notranslate"><span class="pre">World_OSI</span></code> uses <a class="reference internal" href="../../../glossary.html#term-OSI"><span class="xref std std-term">OSI</span></a> as backend storage.
OSI itself uses <code class="docutils literal notranslate"><span class="pre">protobuf</span></code> to describe data structures in a platform independent way by means of <cite>*.proto</cite> files.
When building OSI, these files are converted into C++ headers and sources, using the protobuf compiler <code class="docutils literal notranslate"><span class="pre">protoc</span></code>.
Finally, the sources are then compiled into a library.
<strong>OpenPASS</strong> finally uses the library and the generated headers to interface the library.</p>
<ol class="arabic">
<li><p>Download release 3.2.0 from <a class="reference external" href="https://github.com/OpenSimulationInterface/open-simulation-interface">https://github.com/OpenSimulationInterface/open-simulation-interface</a></p></li>
<li><p>Extract to e.g. <code class="docutils literal notranslate"><span class="pre">C:\OpenPASS\thirdParty\sources\open-simulationinterface</span></code></p></li>
<li><p>Optional: Enable Arenas</p>
<p>For better performance, <strong>openPASS</strong> supports protobuf Arenas allocation (<a class="reference external" href="https://developers.google.com/protocol-buffers/docs/reference/arenas">https://developers.google.com/protocol-buffers/docs/reference/arenas</a>).
To use this feature, OSI and <strong>openPASS</strong> needs to be compiled with Arenas support.
See <a class="reference internal" href="40_cmake.html#cmake-protobuf-arenas"><span class="std std-ref">WITH_EXTENDED_OSI</span></a> how this feature is enabled in <strong>openPASS</strong>.</p>
<p>For OSI, <code class="docutils literal notranslate"><span class="pre">option</span> <span class="pre">cc_enable_arenas</span> <span class="pre">=</span> <span class="pre">true;</span></code> needs to be added <strong>manually</strong> to all OSI proto files before compilation.
If everything goes well, <code class="docutils literal notranslate"><span class="pre">protoc</span></code> will generate all the magic necessary, otherwise issue an error during compilation.</p>
</li>
<li><p>Open <code class="docutils literal notranslate"><span class="pre">MinGW</span> <span class="pre">64-bit</span></code> shell and navigate to extracted folder</p></li>
<li><p>Create build directory</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mkdir build
<span class="nb">cd</span> build
</pre></div>
</div>
</li>
<li><p>Run Cmake</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>cmake -G “MinGW Makefiles” <span class="se">\</span>
-DCMAKE_BUILD_TYPE<span class="o">=</span>Release <span class="se">\</span>
-DCMAKE_INSTALL_PREFIX<span class="o">=</span>C:/OpenPASS/thirdParty <span class="se">\</span>
-DProtobuf_INCLUDE_DIR<span class="o">=</span>C:/OpenPASS/thirdParty/include <span class="se">\</span>
-DProtobuf_PROTOC_EXECUTABLE<span class="o">=</span>C:/OpenPASS/thirdParty/bin/protoc.exe <span class="se">\</span>
-DProtobuf_LIBRARIES<span class="o">=</span>C:/OpenPASS/thirdParty/lib <span class="se">\</span>
..
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Here protobuf is used in as customized prerequisite (see <a class="reference internal" href="#building-protobuf"><span class="std std-ref">Building Protobuf</span></a>).
Adjust paths as needed, if already installed as system package.</p>
</div>
</li>
<li><p>Add linker flags for protobuf</p>
<p>Unfortunantly OSI does not allow for to hook in a custom protobuf library.
To force compilation against a custom library, edit <code class="docutils literal notranslate"><span class="pre">CMakeFiles\open_simulation_interface.dir\linklibs.rsp</span></code>
and add <code class="docutils literal notranslate"><span class="pre">-LC:/OpenPASS/thirdParty/lib</span> <span class="pre">-lprotobuf</span></code> to the end of the line.</p>
<div class="admonition-a-little-bit-hacky admonition">
<p class="admonition-title">A little bit hacky…</p>
<p>If anybody knows how to avoid this step, please let us know.</p>
</div>
</li>
<li><p>Compile</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mingw32-make -j3
</pre></div>
</div>
</li>
<li><p>Install</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mingw32-make install
</pre></div>
</div>
</li>
<li><p>Deprecated: Establish unified layout for prerequisites (c.f. <a class="reference internal" href="#ref-prerequisites"><span class="std std-ref">Referencing Prerequisites</span></a>)</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">cd</span> /C/OpenPASS/thirdParty
cp lib/osi3/libopen_simulation_interface.dll lib
</pre></div>
</div>
</li>
</ol>
<div class="admonition-documentation admonition">
<p class="admonition-title">Documentation</p>
<p>The OSI class documentation is part of the source code and can be compiled using Doxygen.
Instructions are located in the OSI <code class="docutils literal notranslate"><span class="pre">Readme.md</span></code>. A pre-compiled version is located <a class="reference external" href="https://opensimulationinterface.github.io/open-simulation-interface/index.html">here</a>.</p>
<p>So far, the documentation does not include the extensions from the openpass-trafficAgents branch.</p>
</div>
</div>
<div class="section" id="building-protobuf">
<span id="id2"></span><h2>Building Protobuf<a class="headerlink" href="#building-protobuf" title="Permalink to this headline"></a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Protobuf is already available as package for MSYS2 in different versions (see <a class="reference internal" href="50_windows.html#msys2-packages"><span class="std std-ref">Packages</span></a>).</p>
</div>
<p>If a custom build is necessary, adjust this guide to your needs.
Exemplarily, it gives instructions, how to compile version 3.11.4. and hook it into the <strong>openPASS</strong> build.</p>
<ol class="arabic">
<li><p>Download release 3.11.4 from <a class="reference external" href="https://github.com/protocolbuffers/protobuf/releases">https://github.com/protocolbuffers/protobuf/releases</a></p></li>
<li><p>Extract to e.g. <code class="docutils literal notranslate"><span class="pre">C:\OpenPASS\thirdParty\sources\protobuf-cpp-3.11.4</span></code></p></li>
<li><p>Open <code class="docutils literal notranslate"><span class="pre">MinGW</span> <span class="pre">64-bit</span></code> shell and navigate to extracted folder</p></li>
<li><p>Create build directory</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">cd</span> cmake
mkdir build
<span class="nb">cd</span> build
</pre></div>
</div>
</li>
<li><p>Run Cmake</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span> cmake -G <span class="s2">&quot;MinGW Makefiles&quot;</span> <span class="se">\</span>
-DCMAKE_BUILD_TYPE<span class="o">=</span>Release <span class="se">\</span>
-DCMAKE_INSTALL_PREFIX<span class="o">=</span>C:/OpenPASS/thirdParty <span class="se">\</span>
-Dprotobuf_BUILD_SHARED_LIBS<span class="o">=</span>ON <span class="se">\</span>
<span class="hll"> -Dprotobuf_BUILD_TESTS<span class="o">=</span>OFF <span class="se">\</span>
</span> ..
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Tests are disabled due to compiler warnings treated as errors (may vary with compiler version).</p>
</div>
</li>
<li><p>Compile</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mingw32-make -j3
</pre></div>
</div>
</li>
<li><p>Install</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mingw32-make install
</pre></div>
</div>
</li>
<li><p>Deprecated: Establish unified layout for prerequisites (c.f. <a class="reference internal" href="#ref-prerequisites"><span class="std std-ref">Referencing Prerequisites</span></a>)</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">cd</span> /C/OpenPASS/thirdParty
cp bin/libprotobuf.dll lib
</pre></div>
</div>
</li>
</ol>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Please refer to <a class="reference internal" href="50_windows.html#runmingwexe"><span class="std std-ref">Execution</span></a> to see how to run the protobuf compiler <code class="docutils literal notranslate"><span class="pre">protoc.exe</span></code> outside of the <code class="docutils literal notranslate"><span class="pre">MinGW</span> <span class="pre">64-bit</span></code> shell.</p>
</div>
</div>
<div class="section" id="building-fmil">
<span id="id3"></span><h2>Building FMIL<a class="headerlink" href="#building-fmil" title="Permalink to this headline"></a></h2>
<ol class="arabic">
<li><p>Download release 2.0.3 from <a class="reference external" href="https://github.com/modelon-community/fmi-library">https://github.com/modelon-community/fmi-library</a></p></li>
<li><p>Extract to e.g. <code class="docutils literal notranslate"><span class="pre">C:\OpenPASS\thirdParty\sources\fmi-library</span></code></p></li>
<li><p>Open <code class="docutils literal notranslate"><span class="pre">MinGW</span> <span class="pre">64-bit</span></code> shell and navigate to extracted folder</p></li>
<li><p>Create build directory</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mkdir build
<span class="nb">cd</span> build
</pre></div>
</div>
</li>
<li><p>Run Cmake</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>cmake -G <span class="s2">&quot;MinGW Makefiles&quot;</span> <span class="se">\</span>
-DFMILIB_INSTALL_PREFIX<span class="o">=</span>C:/OpenPASS/thirdParty <span class="se">\</span>
-DCMAKE_BUILD_TYPE<span class="o">=</span>Release <span class="se">\</span>
-DFMILIB_BUILD_STATIC_LIB<span class="o">=</span>OFF <span class="se">\</span>
-DFMILIB_BUILD_SHARED_LIB<span class="o">=</span>ON <span class="se">\</span>
..
</pre></div>
</div>
</li>
<li><p>Apply Patch (Linux only)</p>
<p>As FMIL and the internally used <a class="reference external" href="https://github.com/modelica-tools/FMUComplianceChecker">FMU Compliance Checker</a> has issues with loading and private entry points under Linux, the following patch needs to be applied: <a class="reference download internal" download="" href="../../../_downloads/13c83f8af22f3a982e274246191a6807/fmil203.patch"><code class="xref download docutils literal notranslate"><span class="pre">Linux</span> <span class="pre">Patch</span></code></a></p>
</li>
<li><p>Compile</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mingw32-make -j3
</pre></div>
</div>
</li>
<li><p>Install</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mingw32-make install
</pre></div>
</div>
</li>
<li><p>Deprecated: Establish unified layout for prerequisites (c.f. <a class="reference internal" href="#ref-prerequisites"><span class="std std-ref">Referencing Prerequisites</span></a>)</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">cd</span> /C/OpenPASS/thirdParty/include
mkdir FMILibrary
mv -r FMI FMILibrary
mv -r FMI2 FMILibrary
mv -r JM FMILibrary
mv fmilib.h FMILibrary
mv fmilib_config.h FMILibrary
</pre></div>
</div>
</li>
</ol>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="40_cmake.html" class="btn btn-neutral float-right" title="Cmake Build Environment" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="20_prerequisites.html" class="btn btn-neutral float-left" title="Prerequisites" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&#169; Copyright 2021 OpenPASS Working Group.
</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>