Skip to content

Describe installation under Linux and Windows #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions doc/open-simulation-interface_user_guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ include::./architecture/formatting_scripts.adoc[leveloffset=+3]

== Setting up OSI

include::./setup/installing_linux.adoc[leveloffset=+2]
include::./setup/installing_linux_cpp.adoc[leveloffset=+2]

include::./setup/installing_macos.adoc[leveloffset=+2]
include::./setup/installing_linux_python.adoc[leveloffset=+2]

include::./setup/installing_windows_cpp.adoc[leveloffset=+2]

include::./setup/installing_windows.adoc[leveloffset=+2]
include::./setup/installing_windows_python.adoc[leveloffset=+2]

include::./setup/installing_macos.adoc[leveloffset=+2]

include::./setup/using_osi_support_tools.adoc[leveloffset=+2]

Expand Down
11 changes: 0 additions & 11 deletions doc/setup/installing_linux.adoc

This file was deleted.

61 changes: 61 additions & 0 deletions doc/setup/installing_linux_cpp.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
= Installing OSI for C++ on Linux

**Prerequisites**

* You have _cmake_ installed.
* You have installed _protobuf_.
* You must have super user privileges.

**Steps**

. Open a terminal.
. Clone the Open Simulation repository.
+
[source]
----
git clone https://github.com/OpenSimulationInterface/open-simulation-interface.git
----
+
. Change into the repository directory.
+
[source]
----
cd open-simulation-interface
----
+
. Create a new directory for the build.
+
[source]
----
mkdir build
----
+
. Change into the new directory.
+
[source]
----
cd build
----
+
. Run cmake.
To build a 32-bit target under 64-bit linux, add `-DCMAKE_CXX_FLAGS="-m32"` to the cmake command.
In this case, protobuf must be in 32-bit mode too.
+
[source]
----
cmake ..
----
+
. Run make.
+
[source]
----
make
----
+
. Install Open Simulation Interface.
+
[source]
----
sudo make install
----
43 changes: 43 additions & 0 deletions doc/setup/installing_linux_python.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
= Installing OSI for Python on Linux

**Prerequisites**

* You have installed _pip3_.
* You have installed _python-setuptools_.
* You have installed _protobuf_.
* For local installation, you have installed _virtualenv_.

**Steps**

. Open a terminal.
. Clone the Open Simulation repository.
+
[source]
----
git clone https://github.com/OpenSimulationInterface/open-simulation-interface.git
----
+
. Change into the repository directory.
+
[source]
----
cd open-simulation-interface
----
+
. Create a new virtual environment.
+
[source]
----
virtualenv -p python3 venv
----
+
. Activate the virtual environment.
+
[source]
----
source venv/bin/activate
----
+
. Install Open Simulation Interface.
Local installation:: `pip3 install .`
Global installation:: `sudo pip3 install .`
10 changes: 0 additions & 10 deletions doc/setup/installing_windows.adoc

This file was deleted.

54 changes: 54 additions & 0 deletions doc/setup/installing_windows_cpp.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
= Installing OSI for C++ on Windows

**Prerequisites**
Copy link

@kmeids kmeids Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output CCB 09.06.2021:

  1. @pmai will provide a readme to enrich this section, for an easier windows installation process.
  2. This would not hold the merge process and can be adapted afterwards

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using vcpkg to properly build the required configurations of protobuf on Visual Studio (here VS 2017):

  • Install vcpkg as per the documentation, e.g. clone via git the bootstrap as needed

  • English Language pack needs to be installed for VS 2017 for vcpkg to work

  • Create a new triplet file for the required combination of static library linking with dynamic runtime (usually needed for dynamic linking to still work):
    I had to create a file named x64-windows-static-md-v141.cmake in the triplets directory with the following content:

    set(VCPKG_TARGET_ARCHITECTURE x64)
    set(VCPKG_CRT_LINKAGE dynamic)
    set(VCPKG_LIBRARY_LINKAGE static)
    set(VCPKG_PLATFORM_TOOLSET "v141")
    

    Note: only need the v141 suffix and setting of VCPKG_PLATFORM_TOOLSET to ensure VS 2017 is selected if you have newer VS installed (like I had).

  • Now the protobuf libraries can be built automatically using:

    vcpkg.exe install protobuf:x64-windows-static-md-v141
    
  • Once built, they can be automatically used in building the examples by specifying the triplet and toolchain file from VCPKG on the cmake configuration command-line:

    cd examples
    mkdir wbuild
    cd wbuild
    cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static-md-v141 -DCMAKE_TOOLCHAIN_FILE=../../../vcpkg/scripts/buildsystems/vcpkg.cmake -G 'Visual Studio 15 2017 Win64'
    cmake –build .
    

The CMAKE_TOOLCHAIN_FILE must point to your vcpkg directory, which in my example was parallel to the osi-sensor-model-packaging directory…

This might complain somewhat depending on cmake and compiler settings, but builds without problems (and should support release and debug builds out of the box).


* You have installed _cmake_ as administrator.
* You have installed _protobuf_ as administrator.

**Steps**

. Open a terminal as administrator.
. Clone the Open Simulation repository.
+
[source]
----
git clone https://github.com/OpenSimulationInterface/open-simulation-interface.git
----
+
. Change into the repository directory.
+
[source]
----
cd open-simulation-interface
----
+
. Create a new directory for the build.
+
[source]
----
mkdir build
----
+
. Change into the new directory.
+
[source]
----
cd build
----
+
. Run cmake.
To build a 64-bit target, add `Win64` to the generator name.
In this case, protobuf and protoc.exe must be in 64-bit mode too.
+
[source]
----
cmake .. [-G <generator>] [-DCMAKE_INSTALL_PREFIX=<osi-install-directory>]
----
+
. Build and install OSI.
+
[source]
----
cmake --build . [--config Release]
cmake --build . --target install
----
30 changes: 30 additions & 0 deletions doc/setup/installing_windows_python.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
= Installing OSI for Python on Windows

**Prerequisites**

* You have installed _Python_ with administrator rights.
* Make sure _Python_ is added to `PATH`.

**Steps**

. Open a terminal.
. Clone the Open Simulation repository.
+
[source]
----
git clone https://github.com/OpenSimulationInterface/open-simulation-interface.git
----
+
. Change into the repository directory.
+
[source]
----
cd open-simulation-interface
----
+
. Run the setup script.
+
[source]
----
python setup.py install
----