Difference between revisions of "Compiling libFluid"
(Created page with "libFluid is a library of water properties, which provides steam table data for Kraken. libFluid is used in Kraken by compiling its Python bindings and adding those to the Pyt...") |
|||
Line 3: | Line 3: | ||
libFluid is used in Kraken by compiling its Python bindings and adding those to the Python path. | libFluid is used in Kraken by compiling its Python bindings and adding those to the Python path. | ||
− | * Python bindings | + | ==== Prerequisite ==== |
− | ** E.g. | + | * Python bindings require the developer libraries of whichever version of Python you are using |
− | + | ** E.g. <tt>sudo apt install python3.8-dev</tt> | |
* Python bindings require '''pybind11''': | * Python bindings require '''pybind11''': | ||
Line 13: | Line 13: | ||
python -m pip install pybind11 | python -m pip install pybind11 | ||
− | You will also need to add the path of the pybind11 module to your ''environment'' e.g. by adding an export command to the '''postactivate''' file of your kraken virtual environment (see: [[#Setting_up_environment_variables|Setting up environment variables]]): | + | You will also need to add the path of the pybind11 module to your ''environment'' e.g. by adding an export command to the '''postactivate''' file of your kraken virtual environment (see: [[Python_environment#Setting_up_environment_variables|Setting up environment variables]]): |
export pybind11_DIR=/home/<username>/Envs/kraken/lib/python3.<version>/site-packages/pybind11 | export pybind11_DIR=/home/<username>/Envs/kraken/lib/python3.<version>/site-packages/pybind11 | ||
+ | |||
+ | ==== Compiling ==== | ||
* If CMake on your computer is older than version 3.15, you can try changing version number in <tt>cmake_minimum_required(VERSION 3.15)</tt>. find_package(Python) requires CMake version 3.12 or newer. | * If CMake on your computer is older than version 3.15, you can try changing version number in <tt>cmake_minimum_required(VERSION 3.15)</tt>. find_package(Python) requires CMake version 3.12 or newer. | ||
Line 27: | Line 29: | ||
make | make | ||
</pre> | </pre> | ||
− | |||
− | + | If this process leads to CMake partially finding the wrong Python version, you can add the following lines inside <tt>if(LIBFLUID_PYTHON)</tt> for e.g. Python 3.8 | |
find_package(PythonInterp 3.8 REQUIRED) | find_package(PythonInterp 3.8 REQUIRED) | ||
find_package(PythonLibs 3.8 REQUIRED) | find_package(PythonLibs 3.8 REQUIRED) | ||
+ | |||
+ | ==== Final setup ==== | ||
+ | In order to use libFluid with KrakenTools add the <tt>libFluid/build/bindings/Python</tt> folder to your Python path (see [[Python_environment#Adding_folders_to_the_Python_path|Adding folders to the Python path]]). |
Revision as of 08:41, 30 January 2024
libFluid is a library of water properties, which provides steam table data for Kraken.
libFluid is used in Kraken by compiling its Python bindings and adding those to the Python path.
Prerequisite
- Python bindings require the developer libraries of whichever version of Python you are using
- E.g. sudo apt install python3.8-dev
- Python bindings require pybind11:
You can install pybind11 to your kraken virtual environment with
workon kraken python -m pip install pybind11
You will also need to add the path of the pybind11 module to your environment e.g. by adding an export command to the postactivate file of your kraken virtual environment (see: Setting up environment variables):
export pybind11_DIR=/home/<username>/Envs/kraken/lib/python3.<version>/site-packages/pybind11
Compiling
- If CMake on your computer is older than version 3.15, you can try changing version number in cmake_minimum_required(VERSION 3.15). find_package(Python) requires CMake version 3.12 or newer.
- Switch on the building of the Python bindings in the CMakeLists.txt
option(LIBFLUID_PYTHON "Build the Python interface library" ON)
- Configure and build:
mkdir build cd build cmake .. make
If this process leads to CMake partially finding the wrong Python version, you can add the following lines inside if(LIBFLUID_PYTHON) for e.g. Python 3.8
find_package(PythonInterp 3.8 REQUIRED) find_package(PythonLibs 3.8 REQUIRED)
Final setup
In order to use libFluid with KrakenTools add the libFluid/build/bindings/Python folder to your Python path (see Adding folders to the Python path).