Could NOT find LibXml2

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.


I did export the libraries

  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:

-- === 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 (25.7 KB)
CMakeError.log (2.9 KB)

Thank you!

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?

1 Like

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.

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.

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