Difference between revisions of "Compiling libFluid"

From Kraken Wiki
Jump to: navigation, search
(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...")
 
 
(9 intermediate revisions by the same user not shown)
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 include the developer libraries of whichever version of Python you are using
+
==== Prerequisite ====
** E.g.  
+
* Compilation of libFluid uses cmake, which can be installed with
sudo apt install python3.8-dev
+
** <tt>sudo apt install cmake</tt>
 +
* Also needs boost, which could be installed on Ubuntu 23.10 with
 +
** <tt>sudo apt install libboost-dev</tt>
 +
* 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 17:
 
  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
 +
 
 +
'''NB:''' Of course, if your pybind11 was installed in some other location use that directory path on the aforementioned line.
 +
'''After adding this to your environment you will need to reload it.''' Either by starting a new terminal window, or simply by doing a <tt>deactivate</tt> followed by <tt>workon kraken</tt>.
 +
 
 +
==== 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.
* Switch on the building of the Python bindings in the CMakeLists.txt
+
* Switch on the building of the Python bindings in the '''<tt>libFluid/CMakeLists.txt</tt>''':
  option(LIBFLUID_PYTHON "Build the Python interface library" ON)
+
  option(LIBFLUID_PYTHON "Build the Python interface library" '''ON''')
 
* Configure and build:
 
* Configure and build:
 
<pre>
 
<pre>
Line 27: Line 36:
 
make
 
make
 
</pre>
 
</pre>
* In order to use libFluid with KrakenTools add the path to libFluid/build/bindings/Python folder to your Python path (see [[#Adding_folders_to_the_Python_path|Adding folders to the Python path]]).
 
  
* In case 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
+
If this process leads to CMake partially finding the wrong Python version, you can add the following lines to '''<tt>libFluid/CMakeLists.txt</tt>''' 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]]).

Latest revision as of 19:25, 5 February 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

  • Compilation of libFluid uses cmake, which can be installed with
    • sudo apt install cmake
  • Also needs boost, which could be installed on Ubuntu 23.10 with
    • sudo apt install libboost-dev
  • 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

NB: Of course, if your pybind11 was installed in some other location use that directory path on the aforementioned line. After adding this to your environment you will need to reload it. Either by starting a new terminal window, or simply by doing a deactivate followed by workon kraken.

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 libFluid/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 to libFluid/CMakeLists.txt 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).