# Chrono C++ # Background はじめは [Pychrono](https://api.projectchrono.org/pychrono_installation.html) を検証していたが、恐らく本命と思われる [FSI Module](https://api.projectchrono.org/module_fsi_installation.html) の [python demo](https://github.com/projectchrono/chrono/tree/develop/src/demos/python) が無かったり、一部 demo が実行できなかったりで、結局 C++ からコンパイルしてインストールする事にした。 途中まで動いた Pychrono のインストール手順は[こちら](https://hackmd.io/9VHaHOjxTy-hcJ7_DpqBkg) <br> # Outline - [Install](#Install) - [Demo](#Demo) # Install 今回、Docker 環境で用意した container を image化 しておいた。 ※イチからインストールすると面倒い上に、ホストでやると環境を壊しかねない - method A: [docker image から install する](#Install-from-docker) - method B: [始めから install する](#Install-from-scratch) <br> ## Install from docker 自分が作ったイメージを元に install する ### download image これ local にダウンロードする https://ptch365-my.sharepoint.com/personal/kkume_fab_pasona_tech/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fkkume%5Ffab%5Fpasona%5Ftech%2FDocuments%2F00%2EPublic%2FWork%2F20211112%5Fchrono%5Fdocker ### docker load & run & in container ``` docker load -i chrono.nvidia-cudagl-11.2.2-devel-ubuntu20.04.tar xhost + docker run -itd --gpus all --name test -e DISPLAY=unix$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw -v /home/share:/home/share --device /dev/dri chrono:nvidia-cudagl-11.2.2-devel-ubuntu20.04 /bin/bash --login docker exec -it test /bin/bash ``` ### re-make この状態だとGPU関連の module が動かないので再度 make する必要がある ``` cd ~/build_chrono/ ccmake ../chrono/ ``` ![](https://i.imgur.com/RbmTm9L.png) この状態にして、"c", "c", "g" button で genarate して ``` make make install ``` <br> ## Install from scratch 下記を参考にする。 https://api.projectchrono.org/tutorial_install_chrono_linux.html 環境壊したく無いので docker 使って install する ### docker install これは各自で。 ### docker image ``` docker pull nvidia/cudagl:11.2.2-devel-ubuntu20.04 ``` ### docker run ``` xhost + #xhost +local:docker だけでもいけるかも sudo docker run -itd --gpus all --name test -e DISPLAY=unix$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw -v /home/share:/home/share --device /dev/dri nvidia/cudagl:11.2.2-devel-ubuntu20.04 /bin/bash --login ``` ※nvidia/cuda docker の注意 devel じゃないと CUDA 無い https://vasteelab.com/2018/08/07/2018-08-07-141446/ DriverとCUDAの対応関係に注意 https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html ### in container & basic libraries install ``` sudo docker exec -it test /bin/bash cd ~ apt-get update apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev git mesa-utils ``` #### check opengl by command 'glxgears' ``` root@ea0852980383:/# glxgears Running synchronized to the vertical refresh. The framerate should be approximately the same as the monitor refresh rate. X connection to unix:1 broken (explicit kill or server shutdown). root@ea0852980383:/# ``` ### C, C++ latest ``` apt update apt-get install -y software-properties-common add-apt-repository ppa:ubuntu-toolchain-r/test apt update apt-get install -y gcc-11 apt-get install -y --only-upgrade libstdc++6 ``` check ``` root@408866dc21f5:~# strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX GLIBCXX_3.4 GLIBCXX_3.4.1 GLIBCXX_3.4.2 GLIBCXX_3.4.3 GLIBCXX_3.4.4 GLIBCXX_3.4.5 GLIBCXX_3.4.6 GLIBCXX_3.4.7 GLIBCXX_3.4.8 GLIBCXX_3.4.9 GLIBCXX_3.4.10 GLIBCXX_3.4.11 GLIBCXX_3.4.12 GLIBCXX_3.4.13 GLIBCXX_3.4.14 GLIBCXX_3.4.15 GLIBCXX_3.4.16 GLIBCXX_3.4.17 GLIBCXX_3.4.18 GLIBCXX_3.4.19 GLIBCXX_3.4.20 GLIBCXX_3.4.21 GLIBCXX_3.4.22 GLIBCXX_3.4.23 GLIBCXX_3.4.24 GLIBCXX_3.4.25 GLIBCXX_3.4.26 GLIBCXX_3.4.27 GLIBCXX_3.4.28 GLIBCXX_3.4.29 GLIBCXX_DEBUG_MESSAGE_LENGTH root@408866dc21f5:~# /lib/x86_64-linux-gnu/libc.so.6 GNU C Library (Ubuntu GLIBC 2.31-0ubuntu9.2) stable release version 2.31. Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 9.3.0. libc ABIs: UNIQUE IFUNC ABSOLUTE For bug reporting instructions, please see: <https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>. ``` ### Eigen http://eigen.tuxfamily.org/index.php?title=Main_Page#Download ``` cd ~ git clone https://gitlab.com/libeigen/eigen.git cd eigen git checkout 3.3.7 cd ../ mkdir build_eigen cd build_eigen # cmake isntall apt-get install -y cmake-curses-gui cmake ../eigen/ make install ``` ### Irrlicht ``` apt-get install -y libirrlicht1.8 libirrlicht-dev ``` ### Open Cascade https://dev.opencascade.org/release 参考: https://realglitch.com/2020/04/how-to-install-opencascade-7-4-on-ubuntu-18-04-lts/ 1. download from https://dev.opencascade.org/release/previous#node-29988 ``` cd ~ apt-get update apt-get install -y software-properties-common apt-get install -y libtool autoconf automake gfortran gdebi apt-get install -y gcc-multilib libxi-dev libxmu-dev libxmu-headers apt-get install -y libx11-dev mesa-common-dev libglu1-mesa-dev apt-get install -y libfontconfig1-dev apt-get install -y libfreetype6 libfreetype6-dev apt-get install -y tcl tcl-dev tk tk-dev # copy from xxx to ~/opencascade-7.4.0.tgz tar xf opencascade-7.4.0.tgz mkdir build_opencascade cd build_opencascade/ ccmake ../opencascade-7.4.0/ # command c(load config), c(check path and continue), g(generate) # other libraries apt install -y libxi6 libxi-dev libxmu6 libxmu-dev # make make make install ``` ### swig ``` apt-get install -y swig ``` ### other libraries ``` apt-get update apt-get install -y libxxf86vm1 libxxf86vm-dev freeglut3 freeglut3-dev ``` ### Chrono ``` cd ~ git clone https://github.com/projectchrono/chrono.git cd chrono git checkout 6.0.0 git submodule update --init --recursive cd ../ mkdir build_chrono cd build_chrono ccmake ../chrono ``` ![](https://i.imgur.com/yL9a85r.png) ``` export PATH=/usr/local/lib:$PATH export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ```