Jump to content

OpenModelica: Difference between revisions

From NixOS Wiki
added categories
building OpenModelica from source for NixOS 25.05 improved
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{infobox application
  |name=OpenModelica
  |type=Native
  |developer=Open Source Modelica Consortium (OSMC)
  |firstRelease=November 1997
  |latestRelease=1.25.0
  |status=Active
  |license=OSMC Public License
  |os=Linux, macOS, Windows
  |programmingLanguage=Modelica
  |website=[https://openmodelica.org openmodelica.org]
  |github=OpenModelica/OpenModelica
  |bugTracker=[https://github.com/OpenModelica/OpenModelica/issues GitHub]
  |documentation=[https://raw.githubusercontent.com/OpenModelica/OpenModelica-doc/master/OpenModelicaSystem.pdf OpenModelica System Documentation]
}}
[https://openmodelica.org/ 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.
[https://openmodelica.org/ 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.


Line 11: Line 26:


== Build from source ==
== Build from source ==
Here is a <code>shell.nix</code> that nearly works for NixOS 25.05<syntaxhighlight lang="nix" line="1">
See here (working for NixOS 25.05 as of 2025-06-10): https://github.com/MBanucu/NixOS2505BuildOpenModelicaFromSource
{
[[Category:Scientific applications]]
  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"
  '';
}
</syntaxhighlight>
[[Category:Applications]]
[[Category:Science]]

Latest revision as of 19:43, 10 June 2025

OpenModelica

Native Application

Developer(s)Open Source Modelica Consortium (OSMC)
Latest release1.25.0
StatusActive
Operating SystemLinux, macOS, Windows
Language(s)Modelica
LicenseOSMC Public License
External links
Websiteopenmodelica.org
GitHubOpenModelica/OpenModelica
Bug trackerGitHub
DocumentationOpenModelica System Documentation

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:

  1. The installed version will be 1.18.0 but currently (2025-06-09) the latest version is 1.25.0.
  2. One dependency is qtwebkit but this is currently (NixOS 25.05 (Warbler)) marked as an insecure package.
    1. When allowing qtwebkit as insecure package to be installed then during the build process of qtwebkit there are compilation errors.

Build from source

See here (working for NixOS 25.05 as of 2025-06-10): https://github.com/MBanucu/NixOS2505BuildOpenModelicaFromSource