OpenModelica: Difference between revisions
Appearance
create build script for OpenModelica 1.25.0 |
added categories |
||
Line 157: | Line 157: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Applications]] | |||
[[Category:Science]] |
Revision as of 09:47, 9 June 2025
OpenModelica is an open-source modeling and simulation environment for the Modelica language, used for designing, simulating, and analyzing complex dynamic systems. It provides tools for creating models, running simulations, and visualizing results, supporting applications in engineering and science.
Installation
nix-shell -p openmodelica.combined
This is not working. There are several problems:
- The installed version will be 1.18.0 but currently (2025-06-09) the latest version is 1.25.0.
- One dependency is
qtwebkit
but this is currently (NixOS 25.05 (Warbler)) marked as an insecure package.- When allowing
qtwebkit
as insecure package to be installed then during the build process ofqtwebkit
there are compilation errors.
- When allowing
Build from source
Here is a shell.nix
that nearly works for NixOS 25.05
{
pkgs ? import <nixpkgs> {
config.permittedInsecurePackages = [
"python-2.7.18.8"
];
},
}:
let
qtVersion = pkgs.qt5.qtbase.version;
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
autoconf
automake
cmake
ccache
gcc
gnumake
pkg-config
libtool
git
];
buildInputs = with pkgs; [
boost
curl
expat
fontconfig
freetype
gdb
gfortran
gfortran.cc.lib
glibc
hdf5
libffi
libGL
libGL.dev
libxml2
libuuid
lp_solve
openjdk
openblas
openssl
python2
python3
qt5.full
readline
readline.dev
sundials
zlib
openscenegraph
stdenv.cc.libc_dev
icu
xorg.libX11
xorg.libXrandr
xorg.libXinerama
xorg.libXcursor
asciidoc
doxygen
python3Packages.sphinx
flex
opencl-clhpp
ocl-icd
];
shellHook = ''
export LD_LIBRARY_PATH=${
pkgs.lib.makeLibraryPath [
pkgs.boost
pkgs.boost.dev
pkgs.curl
pkgs.curl.dev
pkgs.expat
pkgs.expat.dev
pkgs.fontconfig
pkgs.freetype
pkgs.gfortran.cc.lib
pkgs.glibc.dev
pkgs.hdf5
pkgs.icu.dev
pkgs.libffi
pkgs.libGL
pkgs.libGL.dev
pkgs.libxml2
pkgs.libuuid
pkgs.libuuid.dev
pkgs.lp_solve
pkgs.openblas
pkgs.openssl
pkgs.qt5.full
pkgs.readline
pkgs.readline.dev
pkgs.sundials
pkgs.zlib
pkgs.openscenegraph
pkgs.stdenv.cc.libc_dev
pkgs.xorg.libX11
pkgs.xorg.libXrandr
pkgs.xorg.libXinerama
pkgs.xorg.libXcursor
]
}:$LD_LIBRARY_PATH
# Replace -isystem with -I in NIX_CFLAGS_COMPILE
export NIX_CFLAGS_COMPILE=$(echo "$NIX_CFLAGS_COMPILE" | sed 's/-isystem/-I/g')
export CMAKE_C_FLAGS=$NIX_CFLAGS_COMPILE
export CMAKE_CXX_FLAGS=$NIX_CFLAGS_COMPILE
export CPATH=${pkgs.glibc.dev}/include:${pkgs.stdenv.cc.libc_dev}/include:${pkgs.boost.dev}/include:${pkgs.libuuid.dev}/include:${pkgs.curl.dev}/include:${pkgs.icu.dev}/include:${pkgs.qt5.full}/include:${pkgs.qt5.qtsvg.dev}/include:${pkgs.libGL.dev}/include:${pkgs.readline.dev}/include:${pkgs.openscenegraph}/include:${pkgs.qt5.qtwebengine.dev}/include:${pkgs.expat.dev}/include:$CPATH
# Set QT_PLUGIN_PATH to include Qt plugins
export QT_PLUGIN_PATH=${pkgs.qt5.full}/lib/qt-${qtVersion}/plugins:$QT_PLUGIN_PATH
# Force Qt to use the xcb plugin (X11) by default
export QT_QPA_PLATFORM=xcb
# Clone or update OpenModelica repository to v1.25.0
if [ ! -d "OpenModelica" ]; then
git clone --recurse-submodules https://github.com/OpenModelica/OpenModelica.git
cd OpenModelica
git checkout v1.25.0
git submodule update --force --init --recursive
else
cd OpenModelica
fi
export OPENMODELICAHOME=$(pwd)/build_cmake/install_cmake
echo ""
echo "OpenModelica build environment ready!"
echo "To build OpenModelica with CMake and QT WebEngine, run:"
mkdir -p build_cmake
echo "cmake -S . -B build_cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOM_OMC_ENABLE_FORTRAN=OFF -DOM_OMC_ENABLE_IPOPT=OFF -DOM_OMEDIT_ENABLE_QTWEBENGINE=ON > build_cmake/\$(date +%Y%m%d_%H%M%S)_cmake.txt 2> build_cmake/\$(date +%Y%m%d_%H%M%S)_cmake_error.txt"
echo "cmake --build build_cmake --target install --parallel \$(nproc) > build_cmake/\$(date +%Y%m%d_%H%M%S)_build.txt 2> build_cmake/\$(date +%Y%m%d_%H%M%S)_build_error.txt"
echo ""
echo "Copy libraries from lib64 to lib because omc expects them there"
echo "cp -r $OPENMODELICAHOME/lib64/* $OPENMODELICAHOME/lib"
echo ""
echo "To run OpenModelica, use the command"
echo "$OPENMODELICAHOME/bin/OMEdit"
'';
}