I am trying to compile an example from the manual (Chapter 3 - 1.2 Compiling without CMake) but without success.
The program I am trying to compile is:
#include <igraph.h>
int main() {
igraph_real_t diameter;
igraph_t graph;
igraph_rng_seed(igraph_rng_default(), 42);
igraph_erdos_renyi_game(&graph, IGRAPH_ERDOS_RENYI_GNM, 1000, 3000,
IGRAPH_UNDIRECTED, IGRAPH_NO_LOOPS);
igraph_diameter(&graph, &diameter, 0, 0, 0, IGRAPH_UNDIRECTED, 1);
printf("Diameter of a random graph with average degree %g: %g\n",
2.0 * igraph_ecount(&graph) / igraph_vcount(&graph),
(double) diameter);
igraph_destroy(&graph);
return 0;
}
(No changes to the code from the section 1.1 of the manual).
I try to compile the above code on LinuxMX 19.4 using the following command:
cc igraph_test.c -I/usr/local/include/igraph -L/usr/local/lib -ligraph -o igraph_test
as a result I get a lot undefined referece to errors like:
/usr/bin/ld: /usr/local/lib/libigraph.a(random.c.o): in function `igraph_qnorm5.part.5':
random.c:(.text+0x76d): undefined reference to `exp'
/usr/bin/ld: random.c:(.text+0xa4f): undefined reference to `log'
/usr/bin/ld: random.c:(.text+0xbc9): undefined reference to `expl'
/usr/bin/ld: random.c:(.text+0xd13): undefined reference to `exp'
/usr/bin/ld: random.c:(.text+0xd88): undefined reference to `expl'
/usr/bin/ld: random.c:(.text+0xde9): undefined reference to `sqrt'
/usr/bin/ld: /usr/local/lib/libigraph.a(random.c.o): in function `igraph_rng_get_binom':
random.c:(.text+0x19c6): undefined reference to `log'
/usr/bin/ld: random.c:(.text+0x1ac6): undefined reference to `log'
/usr/bin/ld: random.c:(.text+0x1c83): undefined reference to `log'
/usr/bin/ld: random.c:(.text+0x1d66): undefined reference to `log'
/usr/bin/ld: random.c:(.text+0x1d95): undefined reference to `log'
and a lot more.
The output of pkg-config --libs --cflags igraph
command is
-I/usr/local/include/igraph -L/usr/local/lib -ligraph
so at least this seems to be ok.
I should mention that installing the library using the manual was seamless (or at least I did not get any errors after the “build and test” command at the end of chapter 2.1).