Update compilation authored by Rémy Mozul's avatar Rémy Mozul
# Compilation #
After downloading and uncompressing you must have the `lmgc90_user_xxx` directory somewhere. Inside, you should have the following
subdirectories:
* *src* : the sources of LMGC90 software
* *examples* : the user examples working with the sources
* *manuals* : a list of manuals/documentation for the software in pdf format
* *docs* : the html documentation generated from the sources
* *build* : (empty) where to build the LMGC90 libraries
If an error arises during the compilation step please first check if there is not a solution
in the [FAQ](Faq#compile_error)
You must run a set of commands from the terminal to build LMGC90 software for your system.
## Unix like system (linux, MacOS, WSL) ##
Run the following commands:
```shell
cd build
cmake ..
make
```
#### Python selection ####
It is really important that the compilation process get access to the python version
that the user want to use with lmgc90. As such, it possible to specify the absolute path
to the python executable. For an example, to use python3 on ubuntu 18,
one must run the next line by replacing `[absolute path to python]` by `/usr/bin/python3` (
whereas a macos user will use `/opt/local/bin/python`).
```shell
cd build
cmake .. -DPython_EXECUTABLE=[absolute path to python]
make
```
Or if the user prefers to use *virtual environment* (with or without a manager like [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/#) or [miniconda](https://virtualenvwrapper.readthedocs.io/en/latest/#), then there is two changes:
1. the path to the environment must be provided to cmake
2. lmgc90 must be installed in the environment.
For example when using *virtualenvwrapper* and with an environment called *lmgc90* the compilation steps becomes:
```shell
workon lmgc90
cd build
cmake .. -DVENV_PATH=$VIRTUAL_ENV
make
make install
```
#### Optional compilation ####
Instead of simply running `cmake`, you can run `ccmake` or `cmake-gui` to help you changing some
configuration parameters. For examples to be able to write HDF5 file (assuming you installed the dependancies),
you have to compile with:
```shell
cmake . -DWITH_HDF5=True
make
```
If you want to re-build the documentation run:
```shell
make docs
```
It will build the sphinx documentation in `build/docs` directory,
but the one provided should be up-to-date
#### Installation ####
If a *virtual environment* is used, then the `make install` command has already taken car of this step. It is directly possible to check on the [first steps](./first step) section.
In any other case, our policy is to not mess with default system paths. So our recommendation is
to use an environment variable to add to python the path to our build directory.
In general adding the following lines to your *.bashrc* (Linux) or *.zshrc* (MacOS) file
does the trick. Of course you have to replace *mysourcepath* by the path to your own `lmgc90_user_xxx` directory (something like `/users/name/LMGC90/lmgc90_user_xxx/`
and replacing `xxx` by the version you downloaded).
```shell
if [ -z ${PYTHONPATH} ]; then
export PYTHONPATH=mysourcepath/build
else
export PYTHONPATH=${PYTHONPATH}:mysourcepath/build
fi
export PATH=${PATH}:mysourcepath/src/addons
```
On the use of LMGC90 itself, read the [first steps](./first_steps) section.
## Windows Anaconda ##
If you strictly followed the [dependencies installation](./win_dependencies_install#by-using-python-anaconda-environment-manager)
you can use a powershell script to build LMGC90 with HDF5 feature activated by default.
This script needs to download the sources of HDF5, so make sure that
you have an active connexion to the world wide web before trying to run it.
To run the script, navigate to `lmgc90_user_xxx/conda` in your windows explorer,
then right click on `build_with_hdf5.ps1` and select `execute with powershell`.
If you cannot or would not run script, you can make a standard build by opening
the powershell and activate the *lmgc90* environment
(or whatever the name you choose during the [dependencies installation](./win_dependencies_install#by-using-python-anaconda-environment-manager)
step) with the following command:
```cmd
conda activate lmgc90
```
Then move to `lmgc90_user_xxxx` folder with `cd` command
and build lmgc90 by issuing the following commands:
```cmd
cd build
cmake .. -DVENV_PATH="$env:CONDA_PREFIX" -G "MinGW Makefiles" -DBUILD_rTree_BINDING=OFF
mingw32-make install
..\finalize_conda_env.bat
```
If you made any mistake, it is recommended to close the prompt, to
delete the content of the build directory and start again from scratch.
It is especially important TO NOT RUN the `cmake` command from the
`lmgc90_user_xxxx` directory (see the [faq](./faq#known-compilation-errors))
in this case.
Currently building LMGC90 with openMP is not supported in Anaconda environment.
Whatever the method, if everything went well, then you can start the _Anaconda Navigator_ application.
The first thing is to activate the environment to use LMGC90 by
selection _lmgc90_ in the menu next to _Applications on_ on the upper part of the window.
Then start spyder or jupyter notebook application for example to start using python
with lmgc90 python module available.
On the use of LMGC90 itself, read the [first steps](./first_steps) section.
****
| [back](./Download_and_install) | [home](./Home) | [next](./First_steps) |
|:-------------------------------|:--------------:|-----------------:|
# Compilation #
After downloading and uncompressing you must have the `lmgc90_user_xxx` directory somewhere. Inside, you should have the following
subdirectories:
* *src* : the sources of LMGC90 software
* *examples* : the user examples working with the sources
* *manuals* : a list of manuals/documentation for the software in pdf format
* *docs* : the html documentation generated from the sources
* *build* : (empty) where to build the LMGC90 libraries
If an error arises during the compilation step please first check if there is not a solution
in the [FAQ](Faq#compile_error)
You must run a set of commands from the terminal to build LMGC90 software for your system.
## Unix like system (linux, MacOS, WSL) ##
Run the following commands:
```shell
cd build
cmake ..
make
```
_In case of error during the `make` step on macOS, check [this part of the FAQ](faq#an-error-arise-when-building-on-mac-os)_
#### Python selection ####
It is really important that the compilation process get access to the python version
that the user want to use with lmgc90. As such, it possible to specify the absolute path
to the python executable. For an example, to use python3 on ubuntu 18,
one must run the next line by replacing `[absolute path to python]` by `/usr/bin/python3` (
whereas a macos user will use `/opt/local/bin/python`).
```shell
cd build
cmake .. -DPython_EXECUTABLE=[absolute path to python]
make
```
Or if the user prefers to use *virtual environment* (with or without a manager like [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/#) or [miniconda](https://virtualenvwrapper.readthedocs.io/en/latest/#), then there is two changes:
1. the path to the environment must be provided to cmake
2. lmgc90 must be installed in the environment.
For example when using *virtualenvwrapper* and with an environment called *lmgc90* the compilation steps becomes:
```shell
workon lmgc90
cd build
cmake .. -DVENV_PATH=$VIRTUAL_ENV
make
make install
```
#### Optional compilation ####
Instead of simply running `cmake`, you can run `ccmake` or `cmake-gui` to help you changing some
configuration parameters. For examples to be able to write HDF5 file (assuming you installed the dependancies),
you have to compile with:
```shell
cmake . -DWITH_HDF5=True
make
```
If you want to re-build the documentation run:
```shell
make docs
```
It will build the sphinx documentation in `build/docs` directory,
but the one provided should be up-to-date
#### Installation ####
If a *virtual environment* is used, then the `make install` command has already taken car of this step. It is directly possible to check on the [first steps](./first step) section.
In any other case, our policy is to not mess with default system paths. So our recommendation is
to use an environment variable to add to python the path to our build directory.
In general adding the following lines to your *.bashrc* (Linux) or *.zshrc* (MacOS) file
does the trick. Of course you have to replace *mysourcepath* by the path to your own `lmgc90_user_xxx` directory (something like `/users/name/LMGC90/lmgc90_user_xxx/`
and replacing `xxx` by the version you downloaded).
```shell
if [ -z ${PYTHONPATH} ]; then
export PYTHONPATH=mysourcepath/build
else
export PYTHONPATH=${PYTHONPATH}:mysourcepath/build
fi
export PATH=${PATH}:mysourcepath/src/addons
```
On the use of LMGC90 itself, read the [first steps](./first_steps) section.
## Windows Anaconda ##
If you strictly followed the [dependencies installation](./win_dependencies_install#by-using-python-anaconda-environment-manager)
you can use a powershell script to build LMGC90 with HDF5 feature activated by default.
This script needs to download the sources of HDF5, so make sure that
you have an active connexion to the world wide web before trying to run it.
To run the script, navigate to `lmgc90_user_xxx/conda` in your windows explorer,
then right click on `build_with_hdf5.ps1` and select `execute with powershell`.
If you cannot or would not run script, you can make a standard build by opening
the powershell and activate the *lmgc90* environment
(or whatever the name you choose during the [dependencies installation](./win_dependencies_install#by-using-python-anaconda-environment-manager)
step) with the following command:
```cmd
conda activate lmgc90
```
Then move to `lmgc90_user_xxxx` folder with `cd` command
and build lmgc90 by issuing the following commands:
```cmd
cd build
cmake .. -DVENV_PATH="$env:CONDA_PREFIX" -G "MinGW Makefiles" -DBUILD_rTree_BINDING=OFF
mingw32-make install
..\finalize_conda_env.bat
```
If you made any mistake, it is recommended to close the prompt, to
delete the content of the build directory and start again from scratch.
It is especially important TO NOT RUN the `cmake` command from the
`lmgc90_user_xxxx` directory (see the [faq](./faq#known-compilation-errors))
in this case.
Currently building LMGC90 with openMP is not supported in Anaconda environment.
Whatever the method, if everything went well, then you can start the _Anaconda Navigator_ application.
The first thing is to activate the environment to use LMGC90 by
selection _lmgc90_ in the menu next to _Applications on_ on the upper part of the window.
Then start spyder or jupyter notebook application for example to start using python
with lmgc90 python module available.
On the use of LMGC90 itself, read the [first steps](./first_steps) section.
****
| [back](./Download_and_install) | [home](./Home) | [next](./First_steps) |
|:-------------------------------|:--------------:|-----------------:|