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 |
|---|---|
|
Windows 10 and 11 (run from a Command Prompt) |
|
macOS (Apple Silicon and Intel) |
|
Ubuntu and other Debian-based Linux distributions |
Each script builds and installs:
OpenSees- the Tcl interpreter.opensees.so(opensees.pydon Windows) - the OpenSeesPy Python module.OpenSeesSPandOpenSeesMP- 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:
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.
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.
Git, from https://gitforwindows.org/.
Python, from https://www.python.org/downloads/windows/.
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 namedopensees:mkdir %USERPROFILE%\python_env python -m venv %USERPROFILE%\python_env\opensees
Then activate it:
%USERPROFILE%\python_env\opensees\Scripts\activate.batYour prompt now starts with
(opensees), andpythonandpiprefer to the virtual environment. The activation only lasts for the current Command Prompt, so run theactivate.batcommand again in every new Command Prompt you build OpenSees from. Typedeactivateto 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.
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.
1. Install the requirements
Xcode Command Line Tools. These provide the C/C++ compiler (AppleClang) and Git:
xcode-select --installIf you are told they are already installed, carry on. If the compiler stops working after a macOS update, reinstall them:
sudo rm -rf /Library/Developer/CommandLineTools sudo xcode-select --install
Homebrew, the macOS package manager, from https://brew.sh:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
CMake, the Fortran compiler and the OpenMP library, from Homebrew. The
gccpackage providesgfortran:brew install cmake gcc libomp
Python. Install it from https://www.python.org/downloads/macos/, or use the
python3that comes with the Xcode Command Line Tools. Do not use Homebrew’s Python.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, so nothing you install for OpenSees can break, or be broken by, other Python software on your Mac. Using one for each project is good practice. Keep them together in a folder such as
$HOME/python_env. To create one namedopensees:mkdir -p $HOME/python_env python3 -m venv $HOME/python_env/opensees
Then activate it:
source $HOME/python_env/opensees/bin/activate
Your prompt now starts with
(opensees), andpython3andpiprefer to the virtual environment. The activation only lasts for the current terminal, so run thesourcecommand again in every new terminal you build OpenSees from. Typedeactivateto 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.
Conan 2, the package manager, installed with pip into the active virtual environment:
python3 -m pip install conan
2. Create a folder to build in
Open a new Terminal, 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 $HOME/opensees_build:
source $HOME/python_env/opensees/bin/activate
mkdir -p $HOME/opensees_build
cd $HOME/opensees_build
Type the remaining commands in this Terminal.
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, install MPI and ScaLAPACK, then clone and build MUMPS:
brew install open-mpi scalapack
git clone https://github.com/OpenSees/mumps.git
cd mumps
cmake -S . -B build -Darith=d
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
./makeMac.sh
or, to also build OpenSeesSP and OpenSeesMP:
./makeMac.sh --mumps ../mumps/build
This builds for the architecture of your Mac using the Conan default profile, which the script creates if you don’t have one. The results are installed in $HOME/bin/OpenSeesLatest. The build files are in build.
Building for a specific architecture
The --arch arm64 or --arch x86_64 option builds for that architecture. Use it to make an Intel (x86_64) build on an Apple Silicon Mac, or to keep builds for both architectures side by side:
./makeMac.sh --arch arm64
The build files then go in build_<arch> and the results in $HOME/bin/OpenSeesLatest_<arch>. This option needs a Conan profile named macos-arm64 or macos-x86_64-gcc in ~/.conan2/profiles. For example, macos-arm64 contains:
[settings]
arch=armv8
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=16
os=Macos
os.version=13.0
[conf]
tools.build:compiler_executables={"c": "clang", "cpp": "clang++", "fortran": "gfortran"}
Set compiler.version to the major version shown by clang --version. The x86_64 build uses gcc 15 and gfortran from an Intel (Rosetta) Homebrew install in /usr/local/bin.
1. Install the requirements
Compilers, CMake, Python and LAPACK, from apt:
sudo apt update sudo apt install -y git cmake gcc g++ gfortran python3-dev python3-venv liblapack-dev
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 the system Python can change packages that Ubuntu and other Python software rely on; inside a virtual environment it cannot. Using one for each project is good practice. Keep them together in a folder such as
$HOME/python_env. To create one namedopensees:mkdir -p $HOME/python_env python3 -m venv $HOME/python_env/opensees
Then activate it:
source $HOME/python_env/opensees/bin/activate
Your prompt now starts with
(opensees), andpython3andpiprefer to the virtual environment. The activation only lasts for the current terminal, so run thesourcecommand again in every new terminal you build OpenSees from. Typedeactivateto 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.
Conan 2, the package manager, installed with pip into the active virtual environment:
python3 -m pip install conan
2. Create a folder to build in
Open a new terminal, 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 $HOME/opensees_build:
source $HOME/python_env/opensees/bin/activate
mkdir -p $HOME/opensees_build
cd $HOME/opensees_build
Type the remaining commands in this terminal.
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, install MPI and ScaLAPACK, then clone and build MUMPS:
sudo apt install -y libopenmpi-dev libscalapack-openmpi-dev
git clone https://github.com/OpenSees/mumps.git
cd mumps
cmake -S . -B build -Darith=d
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
./makeUbuntu.sh
or, to also build OpenSeesSP and OpenSeesMP:
./makeUbuntu.sh --mumps ../mumps/build
The results are installed in $HOME/bin/OpenSees. The build files are in build.
2.2. Script Options
All three scripts take the same options:
Option |
Description |
|---|---|
|
The MUMPS build folder. Required, together with MPI, to build OpenSeesSP and OpenSeesMP. |
|
The folder to install into. The default is shown in the tab for your operating system. |
|
The number of files to compile at the same time. The default is the number of cores on your computer. |
|
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 |
|
macOS only. Build for the given architecture (see the macOS tab). |
|
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 |
|
macOS |
|
Ubuntu |
|
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
defaultConan profile if it is missing. The macOS--archoption 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.5to allow them. If you runconan installby 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.dllmust be in the same folder asopensees.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.