Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workaround for GLIBCXX Error #48

Merged
merged 2 commits into from
Jan 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pkg> add https://github.com/precice/PreCICE.jl#<branch-name>

## Troubleshooting

### Custom preCICE installation path

If preCICE is installed at a custom path, errors of the form ```ERROR: could not load library "/..."``` can occur after adding the Julia bindings package. Make sure the preCICE library is in the system library path through `echo $LD_LIBRARY_PATH` and otherwise update the variable with the correct path.

```bash
Expand All @@ -66,6 +68,64 @@ julia> using PreCICE
...
```

### Incompatible version of libstdc++

If you get an error message like:

```julia-repl
ERROR: ERROR: LoadError: LoadError: could not load library "libprecice"
/usr/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/local/lib/libprecice.so)
```

It is caused by an incompatible version of `libstdc++` as described [in the issue](https://github.com/precice/PreCICE.jl/issues/44#issuecomment-1259655654). Julia ships its own libraries, which are older than the ones shipped by the system or the ones used to compile preCICE.

As a first solution, consider updating your julia version. The versions used in Julia are fairly up to date and should work with older systems. The problem is also known to the developers of Julia and they are [working on a solution](https://github.com/JuliaGL/GLFW.jl/issues/198). From Julia `v1.8.3` on, the problem [should be fixed](https://github.com/JuliaLang/julia/pull/46976).

If you cannot update your julia version, or the problem persists, you can try preloading the system `libstdc++`:

<details>
<summary>Click to expand</summary>

Preload the system `libstdc++` with

```bash
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 julia
```

You may have to [compile preCICE from source](https://precice.org/installation-source-preparation.html) for this to work.

On newer systems, preloading only the system `libstdc++` may not be sufficient. Errors of the form

```julia-repl
ERROR: ERROR: LoadError: LoadError: could not load library "libprecice"
/path/to/julia-1.8.1/bin/../lib/julia/libcurl.so: version `CURL_OPENSSL_4' not found (required by /lib/x86_64-linux-gnu/libhdf5_openmpi.so.103)could not load library "libprecice"
/path/to/julia-1.8.1/bin/../lib/julia/libcurl.so: version `CURL_OPENSSL_4' not found (required by /lib/x86_64-linux-gnu/libhdf5_openmpi.so.103)
```

can be resolved by preloading the system `libcurl`:

```bash
LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libcurl.so.4" julia
```

Again, you may have to [compile preCICE from source](https://precice.org/installation-source-preparation.html).

Adding the following lines to your `~/.bashrc` will help to avoid this error in the future:

```bash
alias julia='LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libcurl.so.4" julia'
```

You could instead move the julia libraries out of the way and create a symlink to the system libraries:

```bash
mv /path/to/julia/lib/julia/libstdc++.so.6 /path/to/julia/lib/julia/libstdc++.so.6.bak
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /path/to/julia/lib/julia/libstdc++.so.6
```

If the above approaches do not work, you may have to [compile preCICE from source](https://precice.org/installation-source-preparation.html) using the version of `libstdc++` that is shipped with Julia.
</details>

## Usage

The [solverdummy](https://github.com/precice/julia-bindings/tree/main/solverdummy) shows an example of how to use the Julia bindings for preCICE.
Expand All @@ -82,7 +142,7 @@ pkg> test PreCICE
This checks if the preCICE bindings can be found and accessed correctly.
You can also test the full functionality of PreCICE.jl. If not set up, the output of the previous test shows an info on what command you need to execute. It will be along the lines of:

```
```bash
cd /home/<user>/.julia/packages/PreCICE/<code>/test && make
```

Expand Down