Skip to content

Commit 8430234

Browse files
fsimonisMakisH
andauthored
Cleanup the finding section (#883)
Co-authored-by: Gerasimos Chourdakis <gerasimos.chourdakis@ipvs.uni-stuttgart.de>
1 parent 1d0d9b3 commit 8430234

1 file changed

Lines changed: 63 additions & 40 deletions

File tree

content/docs/installation/building-from-source/installation-source-finding.md

Lines changed: 63 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@ keywords: configuration, basics, cmake, installation, building, source, bash, pr
55
toc: false
66
---
77

8-
If you installed preCICE in a custom prefix, then one still needs to make it discoverable by the system.
8+
If you installed preCICE in a custom prefix, then you still need to make it discoverable by the system.
99

1010
The preCICE library needs to be discoverable in various ways:
1111

12-
1. The location of headers needs to be available during compilation.
12+
1. The location of headers must be available during compilation.
1313
Compilers use hints from `CPATH` if no extra compilation flags were passed to them using `-I`.
14-
2. The shared library needs to be available during linking and execution.
15-
The dynamic linker uses hints from `LD_LIBRARY_PATH` (`DYLD_LIBRARY_PATH` on MacOS X).
16-
3. The preCICE executables need to be in `PATH` (optional, only for additional tools).
14+
2. The shared library must be available during linking and execution.
15+
The dynamic linker uses hints from `LD_LIBRARY_PATH` (`DYLD_LIBRARY_PATH` on macOS).
16+
3. The preCICE executables must be in `PATH` (optional, only for additional tools).
1717

1818
As this setup can become tedious to maintain, there are some tools that expose the above details.
1919
However, they also need to find preCICE in some way:
2020

21-
* `pkg-config` and `pkgconf` use `PKG_CONFIG_PATH` to search for additional `.pc` files.
22-
* `CMake` uses `CMAKE_PREFIX_PATH` for additional installation prefixes.
21+
* pkg-config and pkgconf use `PKG_CONFIG_PATH` to search for additional `.pc` files.
22+
* CMake uses `CMAKE_PREFIX_PATH` for additional installation prefixes.
2323
Alternatively, one can specify the location of the preCICE CMake configuration file using `precice_DIR`.
2424

2525
## Using the shell
2626

27-
If you are using a Unix-like system, you are using a shell, which offers an easy and straight forward way to make preCICE discoverable.
27+
If you are using a Unix-like system, you are using a shell, which offers an easy and straightforward way to make preCICE discoverable.
2828

2929
Let `PRECICE_PREFIX` be the installation prefix chosen during the [preparation step](installation-source-preparation#installation-prefix).
3030
Then add the following to your `.profile` (for bash) or `.zshrc` (for zsh).
3131

3232
```bash
3333
# set this to your selected installation prefix
34-
PRECICE_PREFIX="~/software/prefix"
34+
PRECICE_PREFIX="${HOME}/software/prefix"
35+
3536
export PATH="${PRECICE_PREFIX}/bin:${PATH}"
36-
export LD_LIBRARY_PATH="${PRECICE_PREFIX}/lib:${LD_LIBRARY_PATH}"
37-
export CPATH="${PRECICE_PREFIX}/include:${CPATH}"
38-
# Enable detection with pkg-config and CMake
39-
export PKG_CONFIG_PATH="${PRECICE_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"
40-
export CMAKE_PREFIX_PATH="${PRECICE_PREFIX}:${CMAKE_PREFIX_PATH}"
37+
export CPATH="${PRECICE_PREFIX}/include${CPATH:+:$CPATH}"
38+
export LD_LIBRARY_PATH="${PRECICE_PREFIX}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
39+
export PKG_CONFIG_PATH="${PRECICE_PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
40+
export CMAKE_PREFIX_PATH="${PRECICE_PREFIX}${CMAKE_PREFIX_PATH:+:$CMAKE_PREFIX_PATH}"
4141
```
4242

43-
After adding these variables, start a new session (open a new terminal or logout and login again).
43+
After adding these variables, start a new session (open a new terminal or log out and in again).
4444

4545
## Using systemd environment.d
4646

@@ -58,48 +58,71 @@ Then create a file `~/.config/environment.d/99-precice.conf` with the content:
5858
```conf
5959
# set this to your selected installation prefix
6060
PRECICE_PREFIX="${HOME}/software/prefix"
61+
6162
PATH="${PRECICE_PREFIX}/bin:${PATH}"
62-
LD_LIBRARY_PATH="${PRECICE_PREFIX}/lib:${LD_LIBRARY_PATH}"
63-
CPATH="${PRECICE_PREFIX}/include:${CPATH}"
64-
# Enable detection with pkg-config and CMake
65-
PKG_CONFIG_PATH="${PRECICE_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"
66-
CMAKE_PREFIX_PATH="${PRECICE_PREFIX}:${CMAKE_PREFIX_PATH}"
63+
CPATH="${PRECICE_PREFIX}/include${CPATH:+:$CPATH}"
64+
LD_LIBRARY_PATH="${PRECICE_PREFIX}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
65+
PKG_CONFIG_PATH="${PRECICE_PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
66+
CMAKE_PREFIX_PATH="${PRECICE_PREFIX}${CMAKE_PREFIX_PATH:+:$CMAKE_PREFIX_PATH}"
6767
```
6868

69-
After adding the file, logout and login again. Opening a new terminal will not be sufficient.
69+
After adding the file, log out and in again. Opening a new terminal will **not** be sufficient.
70+
Verify the changes by listing the loaded environment in a new terminal:
7071

71-
## Using directly from the binary directory
72+
```terminal
73+
systemctl show-environment
74+
```
7275

73-
{% warning %}
74-
This method is strongly discouraged unless you are a preCICE developer.
75-
Install preCICE into a prefix unless you have a very good reason not to.
76-
{% endwarning %}
76+
## Using directly from the binary directory
7777

78-
It may not always be practical to install preCICE repeatedly.
79-
This is especially the case for simultaneous development of preCICE and an adapter, or while profiling the internals.
78+
It may not always be practical to reinstall preCICE repeatedly.
79+
This is especially the case for simultaneous development of preCICE and an adapter or while profiling the internals.
8080

81-
This method is discouraged as file layouts are fundamentally different and we make **no** guarantees on keeping them consistent between releases.
82-
Hence, the only reliable methods for using preCICE from the binary directory require `pkg-config` or `CMake`.
83-
If your adapter or solver isn't using one of these methods, then we strongly suggest to install preCICE to a prefix or port the adapter to `pkg-config`.
81+
This method is discouraged as file layouts are fundamentally different, and we make **no** guarantees on keeping them consistent across releases.
82+
Hence, the only reliable methods for using preCICE from the binary directory require pkg-config or CMake.
83+
If your adapter or solver isn't using one of these methods, we strongly suggest installing preCICE to a prefix or porting the adapter to pkg-config or CMake.
8484

85-
First extend `LD_LIBRARY_PATH` with the binary directory if you don't plan to use `rpath` (which `CMake` does by default).
86-
For `pkg-config` users, extend `PKG_CONFIG_PATH` with the binary directory.
87-
For `CMake` users, either set the environment variable `precice_DIR` to the binary directory prior to calling `CMake`, or pass it as a `CMake` variable during configuration.
85+
First, extend `LD_LIBRARY_PATH` with the binary directory if you don't plan to use `rpath` (which CMake does by default).
86+
For pkg-config users, extend `PKG_CONFIG_PATH` with the binary directory.
87+
For CMake users, either set the environment variable `precice_DIR` to the binary directory before calling CMake or pass it as a CMake variable during configuration.
8888

8989
```conf
9090
# Only for using preCICE directly from the build directory
91-
# (as of preCICE v3.3.0 - later versions might differ).
92-
# Prefer installing to a prefix (see above).
91+
# (as of preCICE v3.4.0 - later versions might differ).
9392
9493
PRECICE_BUILD="/path/to/precice/build"
9594
PATH="${PRECICE_BUILD}:${PATH}"
96-
LD_LIBRARY_PATH="${PRECICE_BUILD}:${LD_LIBRARY_PATH}"
97-
PKG_CONFIG_PATH="${PRECICE_BUILD}:${PKG_CONFIG_PATH}"
98-
CMAKE_PREFIX_PATH="${PRECICE_BUILD}:${CMAKE_PREFIX_PATH}"
95+
LD_LIBRARY_PATH="${PRECICE_BUILD}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
96+
PKG_CONFIG_PATH="${PRECICE_BUILD}${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
97+
precice_DIR="${PRECICE_BUILD}"
9998
```
10099

100+
## Verify your installation
101+
102+
First, run:
103+
104+
```terminal
105+
precice-version
106+
```
107+
108+
If the binary `precice-version` cannot be found, then `PATH` is incorrect.
109+
If the library `libprecice.so` cannot be found, then `LD_LIBRARY_PATH` is incorrect.
110+
If the displayed version differs from the version you expect, then you have multiple conflicting preCICE installations on your system.
111+
112+
Next, run:
113+
114+
```terminal
115+
pkg-config --modversion libprecice
116+
```
117+
118+
If `libprecice` wasn't found, then your `PKG_CONFIG_PATH` is incorrect.
119+
If the displayed version differs from the version you expect, then you have multiple conflicting preCICE installations on your system.
120+
121+
At this point, check whether the installation step was successful and whether the used installation prefix contains folders `bin`, `lib`, and `include`.
122+
101123
## Next steps
102124

103-
This concludes the preCICE installation for custom prefixes and you should have a working installation of preCICE on your system.
125+
This concludes the preCICE installation for custom prefixes.
126+
You should now have a working preCICE installation on your system.
104127

105128
To use preCICE in your project, see the page [Linking to preCICE](installation-linking).

0 commit comments

Comments
 (0)