I ran into this tiny error that could have consumed my whole day. I had set up an AWS ubuntu 16.04 (Xenial) image and installed R. I think I followed some random web page and ended up installing the latest version of R v3.4.2
I was trying to install this package “`phangorn“` which has igraph as it’s dependency and lo behold, i could not install it kept failing with this error:
Google turned up a few links that seemed to be helpful including installing libxml2-dev
The link below helped me first trouble shoot the foreign-graphml error #+BEGIN_SRC sh igraph_hacks_internal.h:42:0: warning: “strdup” redefined
^ In file included from /usr/include/string.h:630:0, from src/foreign-gml-parser.y:54: /usr/include/x86_64-linux-gnu/bits/string2.h:1291:0: note: this is the location of the previous definition
^ gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -DUSING_R -I. -Iinclude -Ics -Iglpk -Iplfit -ICHOLMOD/Include -IAMD/Include -ICOLAMD/Include -ISuiteSparse_config -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -DNDEBUG -DNPARTITION -DNTIMER -DNCAMD -DNPRINT -DPACKAGE_VERSION=\”1.1.1\” -DINTERNAL_ARPACK -DIGRAPH_THREAD_LOCAL=/**/ -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c foreign-graphml.c -o foreign-graphml.o foreign-graphml.c: In function ‘igraph_write_graph_graphml’: foreign-graphml.c:1408:46: error: expected ‘)’ before ‘GRAPHML_NAMESPACE_URI’ ret=fprintf(outstream, “<graphml xmlns=\”” GRAPHML_NAMESPACE_URI “\”\n”); ^ foreign-graphml.c:1412:59: error: expected ‘)’ before ‘GRAPHML_NAMESPACE_URI’ ret=fprintf(outstream, ” xsi:schemaLocation=\”” GRAPHML_NAMESPACE_URI “\n”); ^ foreign-graphml.c:1414:38: error: expected ‘)’ before ‘GRAPHML_NAMESPACE_URI’ ret=fprintf(outstream, ” ” GRAPHML_NAMESPACE_URI “/1.0/graphml.xsd\”>\n”); ^ /usr/lib/R/etc/Makeconf:159: recipe for target ‘foreign-graphml.o’ failed make: * [foreign-graphml.o] Error 1 ERROR: compilation failed for package ‘igraph’
ERROR: dependency ‘igraph’ is not available for package ‘phangorn’
The downloaded source packages are in ‘/tmp/Rtmp7mCd4h/downloaded_packages’ Warning messages: 1: In install.packages(“phangorn”, repos = “http://cran.mtu.edu“) : installation of package ‘igraph’ had non-zero exit status 2: In install.packages(“phangorn”, repos = “http://cran.mtu.edu“) : installation of package ‘phangorn’ had non-zero exit status #+END_SRC
However, they all did not seem to be address the second round of errors where ever after compiling, the igraph.so failed to load.
Turns out it was a simple thing to fix. The key is to recognize that the second line of the error message was the culprit, even though it does not actually throw an error
libgfortran.so.4: cannot open shared object file: No such file or directory
There was no libgfortran.so.4 installed on my machine and this is not available by default on Xenial.
ubuntu@ip-172-31-93-178:/usr/local/lib$ find /usr -name "libgfortran*" /usr/share/doc/libgfortran3 /usr/share/doc/libgfortran-5-dev /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a /usr/lib/gcc/x86_64-linux-gnu/5/libgfortranbegin.a /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.so /usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.spec /usr/lib/x86_64-linux-gnu/libgfortran.so.3 /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
However, the R version I had installed was somehow compiled with this version and further investigation reveraled that this was basically part of the gcc-7 toolchain. So, for my purposes I installed gcc-7 and gfortran-7 from a ‘ppa’ on ubuntu based on this SO post and this post. So I added the ppa:jonathonf/gcc-7.1 as specified in one of the comments and then installed as follows
sudo apt-get install gcc-7 g++-7 gfortan-7
the gfortan-7 is key as that is what installs the gfortran command and Voila!!! now I can install igraph.
Hope this is helpful to someone out there. #+END_SRC