Error installing libleidenalg package on a remote cluster. Probably really a question about cmake.

Because I’m on a remote cluster, I had to install igraph in my own directories:

${HOME}/igraph

Now that I am installing the libleidenalg package, I need to tell cmake where the igraph .h files are located, but I cannot figure out how to do that, so I get:

$ export PATH=$PATH:${HOME}/igraph/build
$ /ocean/projects/ibn210001p/mbower/cmake-3.23.0-linux-x86_64/bin/cmake ..
-- Version number from Git: 0.11.0-1-gd46d145
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /jet/home/mbower/libleidenalg/build
$ /ocean/projects/ibn210001p/mbower/cmake-3.23.0-linux-x86_64/bin/cmake --build .
Consolidate compiler generated dependencies of target libleidenalg
[  8%] Building CXX object src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o
In file included from /jet/home/mbower/libleidenalg/src/GraphHelper.cpp:1:
/jet/home/mbower/libleidenalg/include/GraphHelper.h:4:10: fatal error: igraph/igraph.h: No such file or directory
 #include <igraph/igraph.h>
          ^~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [src/CMakeFiles/libleidenalg.dir/build.make:76: src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:116: src/CMakeFiles/libleidenalg.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2
$

How do I tetll “cmake” where to look for .h files?

From the tutorial:

If igraph was installed at a non-standard location, specify its prefix using the -DCMAKE_PREFIX_PATH=... option. The prefix must be the same directory that was specified as the CMAKE_INSTALL_PREFIX when compiling igraph.

I have tried a number of things: different suggested options (“DCMAKE_PREFIX_PATH, igraph_ROOT”, “prefix”, and even good old “I”) and I have tried several different levels of directories ({HOME}, {HOME}/igraph, ${HOME}/igraph/include), along with trying to set the path to “libigraph.a”. Also, I’ve tried “–DCMAKE…” and “-- DCMAKE …” with a space after the “–”, because no-space just gives an “unrecognized option” error. Clearly, I’m no “cmake” expert. :slight_smile:

$ cmake --build . -- DCMAKE_PREFIX_PATH=/jet/home/mbower/igraph
[  8%] Building CXX object src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o
In file included from /jet/home/mbower/libleidenalg/src/GraphHelper.cpp:1:
/jet/home/mbower/libleidenalg/include/GraphHelper.h:4:10: fatal error: igraph/igraph.h: No such file or directory
 #include <igraph/igraph.h>
          ^~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [src/CMakeFiles/libleidenalg.dir/build.make:76: src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:116: src/CMakeFiles/libleidenalg.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2
$

Can you please provide the details on how you installed igraph?

Edit: you want to build a static library?

cd ~
tar xvf igraph-0.10.4.tar
mv igraph-0.10.4 igraph

export CC=/usr/bin/gcc
export CXX=/usr/bin/g++

cd igraph
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/graph
cmake --build
cmake --install

This is a good check as to whether that is the correct sequence for installing igraph, too. :slight_smile:

This is not quite correct. There are two issues:

  • The CMake option is -D, which must be followed by VARIABLE=VALUE syntax.
  • The option must be given at configuration time, not build time.

So, something like:

mkdir build && cd build
cmake .. -DCMAKE_PREFIX_PATH=$HOME/igraph
cmake --build .

Let us know if this worked.

1 Like

You might find this general CMake guide useful:

https://cmake.org/cmake/help/latest/guide/user-interaction/index.html

It shows how to configure, compile and install packages that use CMake.

1 Like

Thank you for the cmake guide! I will take a look. As for the commands (below), I’m still getting the same error. I have run this so many times, should I do some type of “clean” first to clear out caches?

[mbower@v001 build]$ /ocean/projects/ibn210001p/mbower/cmake-3.23.0-linux-x86_64/bin/cmake .. -DCMAKE_PREFIX_PATH=$HOME/igraph
-- Version number from Git: 0.11.0-1-gd46d145
-- Configuring done
-- Generating done
-- Build files have been written to: /jet/home/mbower/libleidenalg/build
[mbower@v001 build]$ /ocean/projects/ibn210001p/mbower/cmake-3.23.0-linux-x86_64/bin/cmake --build .
Consolidate compiler generated dependencies of target libleidenalg
[  8%] Building CXX object src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o
In file included from /jet/home/mbower/libleidenalg/src/GraphHelper.cpp:1:
/jet/home/mbower/libleidenalg/include/GraphHelper.h:4:10: fatal error: igraph/igraph.h: No such file or directory
 #include <igraph/igraph.h>
          ^~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [src/CMakeFiles/libleidenalg.dir/build.make:76: src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:116: src/CMakeFiles/libleidenalg.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2
[mbower@v001 build]$ 

Could you double check whether this might be a typo? That is, for libleidenalg you use $HOME/igraph, not $HOME/graph.

Perhaps you can do a directory listing to verify exactly what the location of igraph.h is?

1 Like

@vtraag, I believe #include <igraph/igraph.h> is not correct. The standard way is #include <igraph.h>. CMake generates a configuration for this method of inclusion. Can you double check this in libleidenalg? I did not look closely myself, at least not yet.

I tested this on my system, and everything works fine. The #include <igraph/igraph.h> does not seem to be a problem, as the compiler appears to be passing -isystem /Users/szhorvat/local/include/igraph -isystem /Users/szhorvat/local/include. So both versions should work.

@markrbower1 Assuming you use the default Unix Makefiles generator, can you post the output of VERBOSE=1 make when building libleidenalg? Do a make clean first if you’ve already built the library once.

I know that (at least on StackOverflow) you aren’t supposed to praise those who help, but many thanks to the “gurus” who are helping me!

@vtraag: I double-checked using $HOME/igraph, but got the same result as before.

@szhorvat: The “verbose” flag always intimidates me, but here goes:

[mbower@v001 build]$ /ocean/projects/ibn210001p/mbower/cmake-3.23.0-linux-x86_64/bin/cmake --build . --verbose
/ocean/projects/ibn210001p/mbower/cmake-3.23.0-linux-x86_64/bin/cmake -S/jet/home/mbower/libleidenalg -B/jet/home/mbower/libleidenalg/build --check-build-system CMakeFiles/Makefile.cmake 0
/ocean/projects/ibn210001p/mbower/cmake-3.23.0-linux-x86_64/bin/cmake -E cmake_progress_start /jet/home/mbower/libleidenalg/build/CMakeFiles /jet/home/mbower/libleidenalg/build//CMakeFiles/progress.marks
/usr/bin/gmake  -f CMakeFiles/Makefile2 all
gmake[1]: Entering directory '/jet/home/mbower/libleidenalg/build'
/usr/bin/gmake  -f src/CMakeFiles/libleidenalg.dir/build.make src/CMakeFiles/libleidenalg.dir/depend
gmake[2]: Entering directory '/jet/home/mbower/libleidenalg/build'
cd /jet/home/mbower/libleidenalg/build && /ocean/projects/ibn210001p/mbower/cmake-3.23.0-linux-x86_64/bin/cmake -E cmake_depends "Unix Makefiles" /jet/home/mbower/libleidenalg /jet/home/mbower/libleidenalg/src /jet/home/mbower/libleidenalg/build /jet/home/mbower/libleidenalg/build/src /jet/home/mbower/libleidenalg/build/src/CMakeFiles/libleidenalg.dir/DependInfo.cmake --color=
Dependencies file "src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o.d" is newer than depends file "/jet/home/mbower/libleidenalg/build/src/CMakeFiles/libleidenalg.dir/compiler_depend.internal".
Consolidate compiler generated dependencies of target libleidenalg
gmake[2]: Leaving directory '/jet/home/mbower/libleidenalg/build'
/usr/bin/gmake  -f src/CMakeFiles/libleidenalg.dir/build.make src/CMakeFiles/libleidenalg.dir/build
gmake[2]: Entering directory '/jet/home/mbower/libleidenalg/build'
[  8%] Building CXX object src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o
cd /jet/home/mbower/libleidenalg/build/src && /usr/bin/c++ -Dlibleidenalg_EXPORTS -I/jet/home/mbower/libleidenalg/build/include -I/jet/home/mbower/libleidenalg/include -isystem /jet/home/mbower/igraph/build/src/CMakeFiles/Export/include/igraph -isystem /jet/home/mbower/igraph/build/src/CMakeFiles/Export/include -fPIC -fvisibility=hidden -std=gnu++11 -MD -MT src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o -MF CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o.d -o CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o -c /jet/home/mbower/libleidenalg/src/GraphHelper.cpp
In file included from /jet/home/mbower/libleidenalg/src/GraphHelper.cpp:1:
/jet/home/mbower/libleidenalg/include/GraphHelper.h:4:10: fatal error: igraph/igraph.h: No such file or directory
 #include <igraph/igraph.h>
          ^~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [src/CMakeFiles/libleidenalg.dir/build.make:76: src/CMakeFiles/libleidenalg.dir/GraphHelper.cpp.o] Error 1
gmake[2]: Leaving directory '/jet/home/mbower/libleidenalg/build'
gmake[1]: *** [CMakeFiles/Makefile2:116: src/CMakeFiles/libleidenalg.dir/all] Error 2
gmake[1]: Leaving directory '/jet/home/mbower/libleidenalg/build'
gmake: *** [Makefile:156: all] Error 2
[mbower@v001 build]$ 

You need to install packages into a different location than where you extracted their sources!

1 Like

Just to make sure to get everything right, here are all the steps to build igraph and libleidenalg:

# Fetch latest version of igraph
curl -LO https://github.com/igraph/igraph/releases/download/0.10.5/igraph-0.10.5.tar.gz
tar xvf igraph-0.10.5.tar.gz

# Create separate build and install directories
mkdir build
mkdir install

# Build igraph
cd build
mkdir igraph/
cd igraph
cmake ../../igraph-0.10.5 -DCMAKE_INSTALL_PREFIX=../../install -DBUILD_SHARED_LIBS=OFF
cmake --build . --target install
cd ../..

# Fetch latest version of libleidenalg
curl -Lo libleidenalg-0.11.0.tar.gz https://github.com/vtraag/libleidenalg/archive/refs/tags/0.11.0.tar.gz
tar xvf libleidenalg-0.11.0.tar.gz

# Build libleidenalg
cd build
mkdir libleidenalg/
cd libleidenalg
cmake ../../libleidenalg-0.11.0 -DCMAKE_INSTALL_PREFIX=../../install -DCMAKE_PREFIX_PATH=../../install -DBUILD_SHARED_LIBS=OFF
cmake --build . --target install
cd ../..

Starting from a directory, i.e. your home directory /jet/home/mbower/, this downloads both tar balls from igraph and libleidenalg in your home directory. It builds it in the build directories build/igraph and build/libleidenalg and installs them in the install directory. Within the install directory, there is then the lib, include and share directory.

I’m not sure how you plan to work with these libraries yourself, but in principle, you could just point to the install/include and install/lib directories to compile/link.

Of course, you can change around the paths as needed by you locally. But perhaps you could just run all these lines exactly as they are, to make sure that everything at least works as intended. If that works, then you can go change paths.

Note that by default igraph builds a static library, while libleidenalg builds a shared library by default, so you have to explicitly specify that you want a static library.

@szhorvat Thank you for that info! That is incredibly helpful!

@vtraag Your script worked perfectly! As a user, that would be super helpful to have available in the README. It’s also nice to serve as a template for downloading and installing other packages.

Many thanks to both of you!

1 Like

Great to hear it worked! I’ll see if I can update the README. In the meantime, you could accept the post as an answer so that others see the solution more quickly.