Installation from source

libOpenCOR can be installed from source for use from:

C++

To build and install the C++ version of libOpenCOR from source, enter the following on the command line:

git clone --depth 1 https://github.com/opencor/libopencor.git libOpenCOR
cd libOpenCOR
cmake -S . -B build -A x64
cmake --build build --config Release
cmake --install build

Note: this will generate a shared version of libOpenCOR. To generate a static version, cmake -S . -B build -A x64 must be replaced with cmake -S . -B build -A x64 -DSHARED_LIBS=OFF.

git clone --depth 1 https://github.com/opencor/libopencor.git libOpenCOR
cd libOpenCOR
cmake -S . -B build
cmake --build build
cmake --install build

Note: this will generate a shared version of libOpenCOR. To generate a static version, cmake -S . -B build must be replaced with cmake -S . -B build -DSHARED_LIBS=OFF.

To test the installation, download and unzip this file, and then enter the following on the command line:

cd cpptest
cmake -S . -B build -A x64 -DCMAKE_PREFIX_PATH="C:\Program Files\libOpenCOR\cmake"
cmake --build build --config Release

This will result in a file called build\Release\cpptest.exe. To run this file will output:

Hello libOpenCOR 0.1.0!

Note: with a shared version of libOpenCOR, the system PATH must contain the directory where libOpenCOR.dll is located, i.e. C:\Program Files\libOpenCOR\bin. Alternatively, libOpenCOR.dll can be copied to the directory where cpptest.exe is located, i.e. build\Release.

cd cpptest
cmake -S . -B build
cmake --build build

This will result in a file called build/cpptest. To run this file will output:

Hello libOpenCOR 0.1.0!

To uninstall libOpenCOR, enter the following on the command line:

cmake --build build --target uninstall

Python

To build and install the Python version of libOpenCOR from source, enter the following on the command line:

pip install git+https://github.com/opencor/libopencor.git

or:

git clone --depth 1 https://github.com/opencor/libopencor.git libOpenCOR
cd libOpenCOR
pip install .

To test the installation, download this file, and then enter the following on the command line:

python test_install.py

To run that Python script will output:

Hello libOpenCOR 0.1.0!

To uninstall libOpenCOR, enter the following on the command line:

pip uninstall -y libopencor