2. Building OpenSees

This chapter explains how to build the OpenSees applications and the OpenSeesPy Python module from source. The build uses CMake to configure and compile the code, and Conan (version 2) to download and build the third-party libraries OpenSees needs (Tcl, HDF5, Eigen and zlib).

The OpenSees repository has a build script for each operating system. You can use to build OpenSees application(s) for you after you have installed all the requirements.

Script

Operating system

makeWIN.bat

Windows 10 and 11 (run from a Command Prompt)

makeMac.sh

macOS (Apple Silicon and Intel)

makeUbuntu.sh

Ubuntu and other Debian-based Linux distributions

Each script builds and installs:

  • OpenSees - the Tcl interpreter.

  • opensees.so (opensees.pyd on Windows) - the OpenSeesPy Python module.

  • OpenSeesSP and OpenSeesMP - the parallel interpreters. These are only built if MPI is installed and you pass the location of a MUMPS build to the script with --mumps.

The steps are: install the requirements for your operating system, create a folder to build in, optionally build MUMPS, obtain the OpenSees source code, then run the script.

Note

The commands in this chapter are typed in a terminal. On Windows use a Command Prompt (type cmd in the Windows search), not PowerShell. On macOS use the Terminal application.

2.1. Requirements and Building

Select your operating system.

1. Install the requirements

Install the following, in this order:

  1. Microsoft Visual Studio. The free Community Edition works. In the Visual Studio Installer, select the Desktop development with C++ workload. This provides the C/C++ compiler, CMake and Ninja.

  2. Intel oneAPI toolkits. From Intel’s oneAPI page install:

    • the Base Toolkit, for the Math Kernel Library (MKL).

    • the HPC Toolkit, for the Fortran compiler (ifx) and Intel MPI.

    Warning

    Install oneAPI after Visual Studio, and keep the Visual Studio integration enabled when asked. If they are installed in the other order, the build fails because no Fortran compiler is found.

    Note

    You do not need an Intel account. After pressing Download, choose Continue as Guest.

  3. Git, from https://gitforwindows.org/.

  4. Python, from https://www.python.org/downloads/windows/.

  5. A Python virtual environment. We strongly recommend installing Conan, and building OpenSeesPy, inside a Python virtual environment. A virtual environment is a private copy of Python with its own packages. Installing Conan into your main Python can change packages that other Python software relies on; inside a virtual environment it cannot. Using one for each project is good practice. Keep them together in a folder such as %USERPROFILE%\python_env. To create one named opensees:

    mkdir %USERPROFILE%\python_env
    python -m venv %USERPROFILE%\python_env\opensees
    

    Then activate it:

    %USERPROFILE%\python_env\opensees\Scripts\activate.bat
    

    Your prompt now starts with (opensees), and python and pip refer to the virtual environment. The activation only lasts for the current Command Prompt, so run the activate.bat command again in every new Command Prompt you build OpenSees from. Type deactivate to leave the environment.

    Note

    OpenSeesPy is built against the Python that is active when the build script runs, so use this same virtual environment when you run OpenSeesPy.

  6. Conan 2, the package manager, installed with pip into the active virtual environment:

    python -m pip install conan
    

2. Create a folder to build in

Open a new Command Prompt, activate your virtual environment, and create and move into a folder that will hold OpenSees and the libraries it depends on. Any folder will do; here it is %USERPROFILE%\opensees_build:

%USERPROFILE%\python_env\opensees\Scripts\activate.bat
mkdir %USERPROFILE%\opensees_build
cd %USERPROFILE%\opensees_build

Type the remaining commands in this Command Prompt.

3. Optional: build MUMPS (for OpenSeesSP and OpenSeesMP)

MUMPS is the parallel solver used by OpenSeesSP and OpenSeesMP. Skip this step if you only need OpenSees and OpenSeesPy. From the build folder, clone and build it:

git clone https://github.com/OpenSees/mumps.git
cd mumps
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64
cmake -S . -B build -G Ninja -Darith=d -DCMAKE_Fortran_COMPILER=ifx -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake --build build --parallel
cd ..

4. Obtain the OpenSees source code

From the build folder, clone the OpenSees repository with Git:

git clone https://github.com/OpenSees/OpenSees.git

This creates a folder named OpenSees next to mumps. To get later updates, type git pull from inside that folder.

If you plan on contributing code to OpenSees, first fork the repository on GitHub and clone your fork instead, replacing YOUR_USER_NAME with your GitHub user name. See Contributing Code & Documentation for how to keep your fork up to date and submit changes.

git clone https://github.com/YOUR_USER_NAME/OpenSees.git

5. Build OpenSees

Move into the OpenSees folder and run the build script:

cd OpenSees
makeWIN.bat

or, to also build OpenSeesSP and OpenSeesMP:

makeWIN.bat --mumps ..\mumps\build

The script sets up the Intel oneAPI environment, checks that conan, cmake, ninja and ifx can be found, and then builds and installs everything. It also copies libiomp5md.dll (the Intel OpenMP runtime) next to the programs, as they will not start without it.

The results are installed in %USERPROFILE%\bin\OpenSeesLatest. The build files are in build\Release.

2.2. Script Options

All three scripts take the same options:

Option

Description

--mumps <dir>

The MUMPS build folder. Required, together with MPI, to build OpenSeesSP and OpenSeesMP.

--prefix <dir>

The folder to install into. The default is shown in the tab for your operating system.

--jobs <n>

The number of files to compile at the same time. The default is the number of cores on your computer.

--no-clean

Keep the existing build folder. By default it is deleted and everything is rebuilt. Use this option after changing source code to recompile only what changed. The build folder is the build subfolder inside the OpenSees folder (build\Release on Windows), not the folder holding mumps and OpenSees ($HOME/opensees_build in the instructions above).

--arch <arm64|x86_64>

macOS only. Build for the given architecture (see the macOS tab).

-h, --help

List the options.

2.3. Using What You Built

Unless you gave a different folder with --prefix, the scripts install into:

Operating system

Install folder

Windows

%USERPROFILE%\bin\OpenSeesLatest

macOS

$HOME/bin/OpenSeesLatest ($HOME/bin/OpenSeesLatest_<arch> with --arch)

Ubuntu

$HOME/bin/OpenSees

The install folder contains:

bin/
   OpenSees            Tcl interpreter (OpenSees.exe on Windows)
   OpenSeesSP          if built with --mumps
   OpenSeesMP          if built with --mumps
   opensees.so         Python module (opensees.pyd on Windows)
   libiomp5md.dll      Windows only
library/
   init.tcl            Tcl startup file

Keep the bin and library folders together. OpenSees looks for library next to bin when it starts.

Tcl: run bin/OpenSees model.tcl, or add the bin folder to your PATH as described in Installation.

Python: OpenSeesPy is imported as opensees. To use the module you built, activate the virtual environment you built it with, then add the bin folder to the PYTHONPATH environment variable. On macOS and Linux:

source $HOME/python_env/opensees/bin/activate
export PYTHONPATH=$HOME/bin/OpenSeesLatest/bin:$PYTHONPATH
python3 -c "import opensees; print(opensees.version())"

On Windows, add the bin folder to PYTHONPATH in Edit the system environment variables.

Warning

The module only works with the Python it was built against. Using any other Python causes an import error or a crash. The cmake output near the start of the build shows which Python was used.

To use your build in place of an installed openseespy package instead, find the module the package uses:

import opensees, inspect
print(inspect.getfile(opensees))

Rename that file to keep it as a backup, then copy your opensees.so (or opensees.pyd) into the same folder.

2.4. What the Scripts Do

You don’t need this section to build OpenSees. It is for developers who want to run the steps by hand or change them. Leaving out the platform-specific settings, each script runs:

# 1. download and build the third-party libraries, and write a CMake toolchain file
conan install . --output-folder=build --build=missing -s build_type=Release

# 2. configure (add -DMUMPS_DIR=<absolute path> for OpenSeesSP & OpenSeesMP)
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_TOOLCHAIN_FILE=build/build/Release/generators/conan_toolchain.cmake

# 3. compile
cmake --build build --parallel
cmake --build build --target OpenSeesPy --parallel

# 4. install
cmake --install build --prefix $HOME/bin/OpenSeesLatest

makeWIN.bat uses build\Release as its build folder and also passes the Ninja generator, the ifx Fortran compiler and the static MKL settings. Read the script for the details.

After the first build, you can recompile a single program from the build folder you already have. For example:

cmake --build build --target OpenSees --parallel

2.5. Troubleshooting

  • conan profile not found. The scripts create the default Conan profile if it is missing. The macOS --arch option needs the profiles described in the macOS tab.

  • Compatibility with CMake < 3.5 has been removed. Some Conan recipes are too old for CMake 4. The scripts set CMAKE_ARGS=-DCMAKE_POLICY_VERSION_MINIMUM=3.5 to allow them. If you run conan install by hand, set the same environment variable first.

  • No Fortran compiler found (Windows). Intel oneAPI was installed before Visual Studio, or without the Visual Studio integration. Reinstall oneAPI.

  • “DLL load failed” when importing opensees (Windows). libiomp5md.dll must be in the same folder as opensees.pyd. The script copies it there, so this usually means the module was copied somewhere else without it.

  • Compile errors in nataf_gsa (macOS). The OpenMP library is missing. Install it with brew install libomp.

  • Python crashes or cannot import opensees. The module is being loaded by a different Python from the one it was built against. See the warning in Using What You Built.