#+BLOG
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
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, "\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’ removing ‘/home/ubuntu/R/x86_64-pc-linux-gnu-library/3.4/igraph’ ERROR: dependency ‘igraph’ is not available for package ‘phangorn’ removing ‘/home/ubuntu/R/x86_64-pc-linux-gnu-library/3.4/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
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 gfortran-7
the gfortran-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
Super useful thanks so much for posting this 🙂
LikeLike
Thanks for the post. I got the same problem when I was installing igraph and this works!
By the way, I guess “gfortan-7” in the last command should be “gfortan-7”. 🙂
LikeLike
Thanks so much, I had the exact same problem and this solved it immediately. There’s a small typo in your last command though, the last R in FORTRAN is missing:
sudo apt-get install gcc-7 g++-7 gfortran-7
LikeLike
Thanks for letting me know. Fixed the typo and glad you found this useful
LikeLike
First time user of R on Linux. I have been using R on Windows for over 15 years. When I tried to install igraph, ran into this error and I resolved it using your solution. Thank you! It makes me appreciate the effort of the R development team who are doing all of this work for users in Windows, who can install the binaries directly. The binaries in Ubuntu repository are not the latest so I needed to install from source and all hell broke loose.
LikeLike