# Could NOT find LibXml2

**URL:** <https://precice.discourse.group/t/could-not-find-libxml2/681>\
**Category:** Installing preCICE\
**Tags:** centos\
**Created:** [August 5, 2021, 3:53pm UTC](https://precice.discourse.group/t/could-not-find-libxml2/681 "2021-08-05T15:53:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JulianSchl](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/julianschl/32/692_2.png) [@JulianSchl](https://precice.discourse.group/u/JulianSchl)\
**Post date:** [August 5, 2021, 3:53pm UTC](https://precice.discourse.group/t/could-not-find-libxml2/681/1 "2021-08-05T15:53:55Z")

</div>

Hi,  
I’m trying to install preCICE v2.2.1 on CentOS Linux 7 (Core), building with CMake v3.15.4.  
Dependency versions:

- boost 1.71.0
- openmpi 3.1.6
- gnu 8.3.0

I was installing libxml2 as stated [here](https://precice.org/installation-source-dependencies.html#install-libxml2-from-source).  
  
  
I did export the libraries

```plaintext
  export LIBRARY_PATH=<prefix>/lib:$LIBRARY_PATH
  export LD_LIBRARY_PATH=<prefix>/lib:$LD_LIBRARY_PATH
  export CPLUS_INCLUDE_PATH=<prefix>/include:$CPLUS_INCLUDE_PATH

```

to the .bashrc and can see the path when calling e.g. `echo $LIBRARY_PATH`. The paths exist.

Now the probblem: Executing  
`cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="$HOME/software/precice" -DPRECICE_PETScMapping=ON -DPETSc_INCLUDE_DIRS="$PETSC_DIR/include" -DPETSc_LIBRARIES="$PETSC_DIR/lib/libpetsc.so" -DPRECICE_PythonActions=OFF -LIBXML2_LIBRARIES="$HOME/software/libxml2/lib/" -LIBXML2_INCLUDE_DIRS="$HOME/software/libxml2/include/" $HOME/software/precice-2.2.1/`  
, I’m getting the following error:

```bash
-- === DEPENDENCIES ===
-- Validating Eigen
-- Validating Prettyprint - success [cached]
CMake Error at /opt/ohpc/pub/utils/cmake/3.15.4/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
Call Stack (most recent call first):
  /opt/ohpc/pub/utils/cmake/3.15.4/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /opt/ohpc/pub/utils/cmake/3.15.4/share/cmake-3.15/Modules/FindLibXml2.cmake:92 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:168 (find_package)

```

Please see the full log attatched below:  
[CMakeOutput.log](https://precice.discourse.group/uploads/short-url/hPuGeCPu3R5H5clFy0pRNM8oV0y.log) (25.7 KB)  
[CMakeError.log](https://precice.discourse.group/uploads/short-url/ijciVBSkMDos8b16Px5v2FZ6OeE.log) (2.9 KB)

Thank you!

---

<div class="post-metadata">

**Author:** ![DavidSCN](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@DavidSCN](https://precice.discourse.group/u/DavidSCN)\
**Post date:** [August 5, 2021, 4:32pm UTC](https://precice.discourse.group/t/could-not-find-libxml2/681/2 "2021-08-05T16:32:46Z")

</div>

Hi,

when defining cmake variables via the command line, you always need to prepend a “D” (for define), i.e., `-D LIBXML2_LIBRARIES="...`. Also, note the difference in the variable spelling between the cmake output and your definitions: `LIBXML2_INCLUDE_DIRS` vs `LIBXML2_INCLUDE_DIR` and similar for the other variable.  
However, once you run `make install` (assuming now you defined the prefix `$HOME/software/libxml2`) and exported the paths as you did cmake should be able to locate libxml2.  
Do you run on a cluster?

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [August 5, 2021, 4:36pm UTC](https://precice.discourse.group/t/could-not-find-libxml2/681/3 "2021-08-05T16:36:34Z")

</div>

Additionally to what David said you could check whether your `libxml2` related paths actually contain the correct files, e.g. is there a `libxml2.so` file in `$HOME/software/libxml2/lib/`?

By the way: According to your output you are using the GNU compilers of version 11.1.0. I am not sure if that is intended since you mention gnu 8.3.0 in your post.

---

<div class="post-metadata">

**Author:** ![JulianSchl](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/julianschl/32/692_2.png) [@JulianSchl](https://precice.discourse.group/u/JulianSchl)\
**Post date:** [August 6, 2021, 10:58am UTC](https://precice.discourse.group/t/could-not-find-libxml2/681/4 "2021-08-06T10:58:34Z")

</div>

Thank you @DavidSCN, adding a “D” did the trick. Also thank you @ajaust for pointing out that my GCC version is not as I expected. I forced the GCC version with `-DCMAKE_CXX_COMPILER="$CXX"`now.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/67d2a5fa6f80e597e2267ff17fa8c1673cd11caa.svg) [@system](https://precice.discourse.group/u/system)\
**Post date:** [August 9, 2021, 10:59am UTC](https://precice.discourse.group/t/could-not-find-libxml2/681/5 "2021-08-09T10:59:14Z")

</div>

Closed on August 9, 2021, 10:59am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
