Compilation on Linux

Andrey

Active CAD practitioner
Staff member
Dear marnixteunissen,

Yes, there is a docker file. Only it is configured for Algo. In addition, the container has not been launched for a long time, so I can not say whether it works now or not. But it seems like it should, since there was no change in third-party components.

1657636048450.png


1657636077149.png
 

Andrey

Active CAD practitioner
Staff member
Dear marnixteunissen,

Yes, there is a docker file. Only it is configured for Algo. In addition, the container has not been launched for a long time, so I can not say whether it works now or not. But it seems like it should, since there was no change in third-party components.

View attachment 329


View attachment 330

marnixteunissen,

Actually, we could check the docker file. We have the corresponding settings in the yml file. Here we need to use either ready-made runners (gitlab terminology) or runners on our machine. We're working on running our own runners, as gitlab's runners might be used by others and it's not guaranteed that we'll be able to wait in line for the CI/CD run.
 
Last edited:

Andrey

Active CAD practitioner
Staff member
marnixteunissen,

Actually, we could check the docker file. We have the corresponding settings in the yml file. Here we need to use either ready-made runners (gitlab terminology) or runners on our machine. We're working on running our own runners, as gitlab's runners might be used by others and it's not guaranteed that we'll be able to wait in line for the CI/CD run.
 

marnixteunissen

CAD practitioner
The Dockerfile in the Analysis Situs repository still works!
There are two things I can't figure out, how to launch the asiExeServer (where to find it), and how i can add my SDK's to the newly built Analysis Situs.
Could you help point me in the right direction?
 

JSlyadne

Administrator
Staff member
The Dockerfile in the Analysis Situs repository still works!
There are two things I can't figure out, how to launch the asiExeServer (where to find it), and how i can add my SDK's to the newly built Analysis Situs.
Could you help point me in the right direction?
Regarding the first question, asiExeServer is the utility generated for "Complete" configuration of AS, so if it's missed, likely, you built AS in "Algo" mode.
 

Quaoar

Administrator
Staff member
If I remember well, we do not have a Dockerfile for the Complete installation mode, but it can be sorted out (we did that in one of our custom projects with some ameliorations). @marnixteunissen, if you happen to have such an operational Dockerfile, feel free to contribute, we'll keep your copyright ;)
 

marnixteunissen

CAD practitioner
If I remember well, we do not have a Dockerfile for the Complete installation mode, but it can be sorted out (we did that in one of our custom projects with some ameliorations). @marnixteunissen, if you happen to have such an operational Dockerfile, feel free to contribute, we'll keep your copyright ;)
I am close to a working docker file, but something in the building process fails.
I am getting all kinds of errors relating to VTK. I have tried building VTK from source, but that gave me errors as well, and I have tried it with the prebuilt binaries, which also failed.
As far as I understand, VTK is only used for the visualization in AS, which I'm not planning to use.
Is there a way to build AS without VTK?
I have attached the dockerfile i'm using now, i am trying to build without rapidjson, since that gave me errors in the cmake configuration
 

Attachments

  • Dockerfile.txt
    9 KB · Views: 2

lisp

Looking around for some CAD
Code:
FROM ubuntu:latest


###############################################################################
#
# - OpenCascade:    this is the geometric modeling kernel which provides the
#                   essential services such as B-rep modeling & shape
#                   interrogation, data exchange, shape healing, etc.
#                   https://github.com/Open-Cascade-SAS/OCCT
#
# - Analysis Situs: the open-source CAD platform providing the feature recognition
#                   services, data model, VTK-based visualization services for
#                   CAD models, and GUI/scripting prototyping framework.
#                   https://gitlab.com/ssv/AnalysisSitus
#
# - Eigen:          linear algebra, vectors, matrices.
#                   https://eigen.tuxfamily.org/index.php?title=Main_Page
#
# - Rapidjson:      output to JSON and export to glTF (Analysis Situs).
#                   https://rapidjson.org
#
# Ex. to build:
# > docker build --pull --rm -f "Dockerfile" -t AS:latest "." --no-cache
###############################################################################


ENV DEBIAN_FRONTEND=noninteractive


RUN apt-get update


# Build tools.
RUN apt-get -y install build-essential git cmake


# 3-rd parties for OCCT
RUN apt-get -y install tcl tcl-dev tk tk-dev libfreeimage-dev
RUN apt-get -y install libxmu-dev libxi-dev
RUN apt-get -y install libosmesa6-dev


# Xvfb provides an X server that can run on machines with no
# display hardware and no physical input devices. It emulates a
# dumb framebuffer using virtual memory.
RUN apt-get -y install xvfb


# Extra 3-rd parties for Analysis Situs
RUN apt-get -y install libeigen3-dev rapidjson-dev


# OpenCascade
RUN git clone https://github.com/Open-Cascade-SAS/OCCT.git opencascade
WORKDIR /opencascade
RUN git checkout V7_4_0 -b AS
RUN mkdir -p build
WORKDIR /opencascade/build
RUN cmake .. \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_RPATH="" \
  -DCMAKE_INSTALL_PREFIX=/usr \
  -DUSE_FREEIMAGE=ON \
  -DUSE_FFMPEG=OFF \
  -DUSE_VTK=OFF \
  -DUSE_TBB=OFF
RUN make
RUN make install


# Copy sources of AS
COPY cmake          /as/cmake
COPY src            /as/src
COPY data           /as/data
COPY CMakeLists.txt /as


WORKDIR /as/
RUN mkdir -p build
WORKDIR /as/build


# INSTALL QT5:
RUN \
    set -eux && \
    apt-get update && \
    apt-get -y upgrade && \
    apt-get -y install \
        aptitude apt-rdepends bash ccache clang clang-tidy cmake cppcheck curl doxygen diffstat gawk gdb git gnupg gperf iputils-ping \
        libboost-all-dev libfcgi-dev libgfortran5 libgl1-mesa-dev libjemalloc-dev libjemalloc2 libmlpack-dev libtbb-dev libyaml-cpp-dev \
        linux-tools-generic nano nasm ninja-build openjdk-11-jdk openssh-server openssl pkg-config python3 qt5-default spawn-fcgi \
        sudo tini unzip valgrind wget zip texinfo gcc-multilib chrpath socat cpio xz-utils debianutils libegl1-mesa \
        patch perl tar rsync bc libelf-dev libssl-dev libsdl1.2-dev xterm mesa-common-dev whois software-properties-common \
        libx11-xcb-dev libxcb-dri3-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev \
        libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-util-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-xkb-dev xorg-dev \
        libconfuse-dev libnl-3-dev libnl-route-3-dev libncurses-dev dh-autoreconf freeglut3 freeglut3-dev libglfw3-dev \
        apt-transport-https g++ graphviz xdot golang-go && \
    curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/bazel.gpg && \
    echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \
    apt-get update && \
    apt-get -y install bazel && \
    bazel --version && \
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb && \
    sudo dpkg -i cuda-keyring_1.0-1_all.deb && \
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin && \
    mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \
    apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub && \
    add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" && \
    apt-get update && \
    apt-get -y install cuda && \
    apt-get -y autoremove && \
    apt-get -y autoclean && \
    apt-get -y clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    exit 0
# Install python pip
RUN \
    set -eux && \
    python3 --version && \
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
    python3 get-pip.py && \
    rm get-pip.py && \
    python3 -m pip install -U pip && \
    pip3 --version && \
    pip3 install --upgrade pip setuptools wheel && \
    pip3 --version && \
    exit 0
# Install python pip packages
RUN \
    set -eux && \
    pip3 --version && \
    pip3 install --upgrade pip setuptools wheel && \
    pip3 --version && \
    pip3 install --upgrade autoenv autopep8 cmake-format clang-format conan conan_package_tools meson && \
    pip3 install --upgrade cppclean flawfinder lizard pygments pybind11 GitPython pexpect subunit Jinja2 pylint CLinters && \
    pip3 install --upgrade ipython jupyter matplotlib nose numba numpy pandas pymc3 PyWavelets requests scikit-learn scipy seaborn sympy quandl textblob nltk yfinance && \
    exit 0
RUN pip3 install --upgrade PyPortfolioOpt
RUN pip3 install --upgrade dlib -vvv
RUN pip3 install --upgrade frida frida-tools
RUN pip3 install --upgrade vaex
#RUN pip3 install --upgrade --ignore-installed cltk
# Install FB Prophet
# https://github.com/facebook/prophet/blob/master/python/requirements.txt
RUN \
    pip3 install --upgrade Cython cmdstanpy==0.9.68 pystan~=2.19.1.1 numpy pandas matplotlib LunarCalendar convertdate holidays setuptools-git python-dateutil tqdm && \
    pip3 install --upgrade fbprophet && \
    exit 0
# Install conan
RUN \
    set -eux && \
    conan profile new default --detect  && \
    conan profile update settings.compiler.libcxx=libstdc++11 default && \
    conan remote list && \
    conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan && \
    exit 0
# Install buildifier
Run go get github.com/bazelbuild/buildtools/buildifier
# Setup ssh
RUN \
    set -eux && \
    mkdir -p /var/run/sshd && \
    mkdir -p /root/.ssh && \
    sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config && \
    sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config && \
    groupadd -g 1000 myuser && \
    useradd --system --no-log-init --create-home --home-dir /home/myuser --gid myuser --groups sudo --uid 1000 --shell /bin/bash myuser && \
    echo 'root:root' | chpasswd && \
    echo 'myuser:myuser' | chpasswd && \
    ssh-keygen -A && \
    exit 0
RUN sudo apt-get update -y
RUN sudo apt-get install -y qttools5-dev-tools
ENV IGNORE_CC_MISMATCH=1
ENV PATH=$PATH:/usr/local/cuda/bin
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/usr/sbin/sshd", "-D", "-e"]
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
RUN sed -i 's/ universe/ universe multiverse/' /etc/apt/sources.list
RUN apt update &&                  \
    apt upgrade -y &&              \
    apt dist-upgrade -y &&         \
    apt install -y                 \
        xvfb                       \
        flex                       \
        dh-make                    \
        debhelper                  \
        checkinstall               \
        fuse                       \
        bison                      \
        libxcursor-dev             \
        libxcomposite-dev          \
        libxcb1-dev                \
        libx11-dev                 \
        libudev-dev                \
        qtbase5-private-dev      &&\
    apt clean


# Installing QT5
RUN apt-get install libqt5x11extras5-dev qt5-default -y
RUN sudo apt install mesa-utils -y


COPY install_vtk.sh /home


COPY VTK-8.2.0-install /home/vtk-install
COPY tcltk-86-64 /home/tcl-install
COPY freetype-2.5.5-vc14-64 /home/freetype-install


# Analysis Situs
RUN cmake .. \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/usr/local \
  -DCMAKE_INSTALL_RPATH="" \
  -DINSTALL_DIR=/usr/local/bin/analysissitus \
  -DDISTRIBUTION_TYPE=Complete \
  -D3RDPARTY_DIR=/usr/lib \
  -D3RDPARTY_OCCT_INCLUDE_DIR=/usr/include/opencascade \
  -D3RDPARTY_OCCT_LIBRARY_DIR=/usr/lib \
  -D3RDPARTY_EIGEN_DIR=/usr/include/eigen3/ \
  -D3RDPARTY_QT_DIR_NAME=/usr/lib/qt5/ \
  -D3RDPARTY_tcl_DIR=/usr \
  -D3RDPARTY_vtk_DIR=/usr \
  -D3RDPARTY_freetype_DIR=/usr \
  -DUSE_MOBIUS=off \
  -DUSE_INSTANT_MESHES=off \
  -DUSE_RAPIDJSON=off \
  -DUSE_NETGEN=off \
  -DUSE_THREADING=off \
  -D3RDPARTY_DIR=/usr/lib
RUN make
RUN make install
 

lisp

Looking around for some CAD
I just made a forum account and copied and pasted the Dockerfile.txt of the previous response. I still haven't figured out how to build the code in my Linux system.
 

JohannesV

Looking around for some CAD
Hi, thanks for this great application (and general OCC tutorials) Quaoar, really appreciated.

I got the Dockerfile working for the Analysis Situs 1.1.0 release. Make sure to checkout this version before starting the build. Replace the existing Dockerfile with this one and build it with:
```
sudo docker build -t analysis-situs:latest .
```

Code:
FROM ubuntu:20.04

# NOTE: This Dockerfile works with version v1.1.0 of Analysis Situs (requiring OCC 7.4.0)
#  The development branch of Analysis Situs requires a newer version of OCC

###############################################################################
#
# - OpenCascade:    this is the geometric modeling kernel which provides the
#                   essential services such as B-rep modeling & shape
#                   interrogation, data exchange, shape healing, etc.
#                   https://github.com/Open-Cascade-SAS/OCCT
#
# - Analysis Situs: the open-source CAD platform providing the feature recognition
#                   services, data model, VTK-based visualization services for
#                   CAD models, and GUI/scripting prototyping framework.
#                   https://gitlab.com/ssv/AnalysisSitus
#
# - Eigen:          linear algebra, vectors, matrices.
#                   https://eigen.tuxfamily.org/index.php?title=Main_Page
#
# - Rapidjson:      output to JSON and export to glTF (Analysis Situs).
#                   https://rapidjson.org
#
# Ex. to build:
# > docker build --pull --rm -f "Dockerfile" -t AS:latest "." --no-cache
###############################################################################


ENV DEBIAN_FRONTEND=noninteractive


RUN apt-get update


RUN apt-get -y install build-essential git cmake wget

# Installing QT
# =============
RUN apt-get -y install qtcreator qt5-default
RUN apt-get -y install libqt5x11extras5-dev
RUN apt-get -y install qttools5-dev

# Building VTK
# ============
# VTK dependencies
RUN apt-get -y install libxt-dev libgl1-mesa-dev
# VTK
WORKDIR /home
RUN wget https://www.vtk.org/files/release/8.2/VTK-8.2.0.tar.gz
RUN tar xvfz ./VTK-8.2.0.tar.gz
WORKDIR /home/VTK-8.2.0
RUN mkdir build
WORKDIR /home/VTK-8.2.0/build
RUN cmake .. \
  -DVTK_Group_Qt=ON \
  -DVTK_QT_VERSION=5 \
  -DVTK_RENDERING_BACKEND=OpenGL2 \
  -DVTK_Group_Imaging=YES \
  -DVTK_Group_Qt=YES \
  -DVTK_Group_Views=YES \
  -DBUILD_SHARED_LIBS=ON \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/usr
RUN make -j8
RUN make -j8 install

# Building OpenCascade
# ====================
# Opencascade dependencies
RUN apt-get install -y tcl tcl-dev tk tk-dev libfreeimage-dev
RUN apt-get install -y libxmu-dev libxi-dev
RUN apt-get install -y libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev libosmesa6-dev
# Following dependencies might only be needed in a docker image, not on a host
RUN apt-get install -y libqt5gui5 && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y xvfb
# OpenCascade
RUN mkdir /home/opencascade
WORKDIR /home/opencascade
RUN wget https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_4_0.tar.gz
RUN tar zxvf V7_4_0.tar.gz
RUN mkdir /home/opencascade/OCCT-7_4_0/build
WORKDIR /home/opencascade/OCCT-7_4_0/build
RUN cmake .. \
    -DCMAKE_BUILD_TYPE=release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DUSE_FREEIMAGE=ON
RUN make -j8
RUN make -j8 install

# Installing Freetype
# ===================
RUN apt-get install -y libfreetype6-dev

# Building Analysis Situs
# =======================
# Copy sources of Analysis Situs
COPY cmake          /as/cmake
COPY src            /as/src
COPY data           /as/data
COPY asiExe.sh      /as
COPY CMakeLists.txt /as
# Analysis Situs dependencies
RUN apt-get -y install libeigen3-dev rapidjson-dev
# Hack: symlink the VTK build/lib directory to /usr/lib/vtk-8.2, as the VTK installation doesn't seem to
# copy its files to the /usr/lib directory
RUN ln -s /home/VTK-8.2.0/build/lib /usr/lib/vtk-8.2
# Analysis Situs
WORKDIR /as
RUN mkdir -p build
WORKDIR /as/build
RUN cmake .. \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/usr/local \
  -DCMAKE_INSTALL_RPATH="" \
  -DINSTALL_DIR=/usr/local/bin/analysissitus \
  -DDISTRIBUTION_TYPE=Complete \
  -D3RDPARTY_DIR=/usr/lib \
  -D3RDPARTY_OCCT_INCLUDE_DIR=/usr/include/opencascade \
  -D3RDPARTY_OCCT_LIBRARY_DIR=/usr/lib \
  -D3RDPARTY_EIGEN_DIR=/usr/include/eigen3/ \
  -D3RDPARTY_QT_DIR_NAME=/usr/lib/qt5/ \
  -D3RDPARTY_tcl_DIR=/usr/lib/x86_64-linux-gnu \
  -D3RDPARTY_tcl_INCLUDE_DIR=/usr/include/tcl8.6 \
  -D3RDPARTY_tcl_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
  -D3RDPARTY_vtk_DIR=/usr \
  -D3RDPARTY_vtk_INCLUDE_DIR=/usr/include/vtk-8.2 \
  -D3RDPARTY_vtk_LIBRARY_DIR=/usr/lib/vtk-8.2 \
  -D3RDPARTY_freetype_DIR=/usr \
  -D3RDPARTY_freetype_INCLUDE_DIR=/usr/include/freetype2 \
  -D3RDPARTY_freetype_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
  -DUSE_MOBIUS=off \
  -DUSE_INSTANT_MESHES=off \
  -DUSE_RAPIDJSON=off \
  -DUSE_NETGEN=off \
  -DUSE_THREADING=off \
  -D3RDPARTY_DIR=/usr/lib
RUN make -j8
RUN make -j8 install

WORKDIR /usr/local/bin/analysissitus/bin

CMD ./asiExe.sh
 
Last edited:

JohannesV

Looking around for some CAD
To make sure the docker container has access to your host display, you can use the following little script. Save the code below as `run-docker-with-display.sh` and
```
./run-docker-with-display.sh -it analysis-situs:latest
```


Bash:
#!/bin/bash

############################################################
# Help                                                     #
############################################################
Help()
{
   # Display Help
   echo "This script can be used to extend 'sudo docker run' commands such that the created container allows passing any visual output to the host display."
   echo
   echo "Usage: $0 <docker run arguments>"
   echo
   echo "Example usage: $0 -it analysis-situs:latest"
   echo
}


############################################################
# Main program                                             #
############################################################
# If no arguments are provided, print the help and exit.
if [ $# -eq 0 ]; then
  Help
  exit 1
fi

# Otherwise perform a `sudo docker run` command with the given arguments
xhost +local:docker
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
sudo docker run -e DISPLAY=$DISPLAY -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH --privileged $@
xhost -local:docker
 
Last edited:

Quaoar

Administrator
Staff member
@JohannesV

Awesome! I changed the OpenCascade version to 7.6.0 and it compiled master branch without any troubles. Then I run the executable with

Code:
docker run --rm -it -e DISPLAY=192.168.1.42:0.0 analysis-situs:latest

using my local IP address for the X server and VcXsrv on Windows.

Your Dockerfile definitely deserves pushing to the master branch, I'll proceed with it.

1682698334051.png
 

Gordan

CAD practitioner
Thanks for this- I was not able to get AS to compile with OpenCascade master, I used 7.4. Oddly, compiling 7.4.0 gave some linker issue that was not present on master, but I was able to point ld to the correct libraries with symlinks. The integration of Active Data makes sense, I wasn't sure why this parameter was not required for AS anymore :) I see the script, and asiExe is present in my build directory, so I'll try to use those together. Thanks again for the help!
Hello,

Can confirm same behavior with asiExe on my setup. After copying 'asiExe' and 'asiExe.sh' from the build directory to the install bin directory, the application can be run.

Additionally, on the first compilation I used occt 7.7.1 which compiled successfully but the shared libs links were broken after installation, indicated by the red colored names of the .so files as in the 'install_bin.png' provided by @sala. Using OCCT 7.6.0 resolved the issues.

Best Regards!
- Gordan
 
Top