igraph installation from source in R - compilation failed

Installing igraph from source (1.3.0) gives me the following error:

> install.packages("igraph")
Installing package into ‘C:/Users/b420054/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)

  There is a binary version available but the source version is later:
       binary source needs_compilation
igraph  1.3.0  1.4.1              TRUE

installing the source package ‘igraph’

trying URL 'https://cran.mirror.ac.za/src/contrib/igraph_1.4.1.tar.gz'
Content type 'application/octet-stream' length 2910158 bytes (2.8 MB)
downloaded 2.8 MB

Microsoft R Open 4.0.2
The enhanced R distribution from Microsoft
Microsoft packages Copyright (C) 2020 Microsoft Corporation

Using the Intel MKL for parallel mathematical computing (using 14 cores).

Default CRAN mirror snapshot taken on 2020-07-16.
See: https://mran.microsoft.com/.


* installing *source* package 'igraph' ...
** package 'igraph' successfully unpacked and MD5 sums checked
** using staged installation
** libs
"C:/rtools40/mingw64/bin/"gcc -m64 -I"C:/PROGRA~1/MIE74D~1/ROPEN~1/R-40~1.2/include" -DNDEBUG -I/mingw64/include/libxml2 -I/mingw64/include -DLIBXML_STATIC -DUSING_R -DHAVE_FMEMOPEN=0 -DHAVE_OPEN_MEMSTREAM=0 -DHAVE_RINTF -DHAVE_STRCASECMP -DWin32 -DHAVE_LIBXML=1 -DHAVE_UNISTD_H -Wall -DHAVE_FMIN=1 -DHAVE_LOG2=1 -DHAVE_GFORTRAN -DINTERNAL_ARPACK -I/mingw64/include -DHAVE_GLPK=1 -DIGRAPH_THREAD_LOCAL= -DPRPACK_IGRAPH_SUPPORT -I. -Icore -Iinclude -Ivendor -DNDEBUG -DNTIMER -DNPRINT -I/mingw64/include    -I"C:/a/w/1/s/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c core/centrality/betweenness.c -o core/centrality/betweenness.o
"C:/rtools40/mingw64/bin/"gcc -m64 -I"C:/PROGRA~1/MIE74D~1/ROPEN~1/R-40~1.2/include" -DNDEBUG -I/mingw64/include/libxml2 -I/mingw64/include -DLIBXML_STATIC -DUSING_R -DHAVE_FMEMOPEN=0 -DHAVE_OPEN_MEMSTREAM=0 -DHAVE_RINTF -DHAVE_STRCASECMP -DWin32 -DHAVE_LIBXML=1 -DHAVE_UNISTD_H -Wall -DHAVE_FMIN=1 -DHAVE_LOG2=1 -DHAVE_GFORTRAN -DINTERNAL_ARPACK -I/mingw64/include -DHAVE_GLPK=1 -DIGRAPH_THREAD_LOCAL= -DPRPACK_IGRAPH_SUPPORT -I. -Icore -Iinclude -Ivendor -DNDEBUG -DNTIMER -DNPRINT -I/mingw64/include    -I"C:/a/w/1/s/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c core/centrality/centrality_other.c -o core/centrality/centrality_other.o

---- I had to remove some of the log due to Topic length constraints in Discord -----


core/scg/scg_optimal_method.o core/scg/scg_utils.o core/version.o vendor/cs/cs_add.o vendor/cs/cs_amd.o vendor/cs/cs_chol.o vendor/cs/cs_cholsol.o vendor/cs/cs_compress.o vendor/cs/cs_counts.o vendor/cs/cs_cumsum.o vendor/cs/cs_dfs.o vendor/cs/cs_dmperm.o vendor/cs/cs_droptol.o vendor/cs/cs_dropzeros.o vendor/cs/cs_dupl.o vendor/cs/cs_entry.o vendor/cs/cs_ereach.o vendor/cs/cs_etree.o vendor/cs/cs_fkeep.o vendor/cs/cs_gaxpy.o vendor/cs/cs_happly.o vendor/cs/cs_house.o vendor/cs/cs_ipvec.o vendor/cs/cs_leaf.o vendor/cs/cs_load.o vendor/cs/cs_lsolve.o vendor/cs/cs_ltsolve.o vendor/cs/cs_lu.o vendor/cs/cs_lusol.o vendor/cs/cs_malloc.o vendor/cs/cs_maxtrans.o vendor/cs/cs_multiply.o vendor/cs/cs_norm.o vendor/cs/cs_permute.o vendor/cs/cs_pinv.o vendor/cs/cs_post.o vendor/cs/cs_print.o vendor/cs/cs_pvec.o vendor/cs/cs_qr.o vendor/cs/cs_qrsol.o vendor/cs/cs_randperm.o vendor/cs/cs_reach.o vendor/cs/cs_scatter.o vendor/cs/cs_scc.o vendor/cs/cs_schol.o vendor/cs/cs_spsolve.o vendor/cs/cs_sqr.o vendor/cs/cs_symperm.o vendor/cs/cs_tdfs.o vendor/cs/cs_transpose.o vendor/cs/cs_updown.o vendor/cs/cs_usolve.o vendor/cs/cs_util.o vendor/cs/cs_utsolve.o vendor/mini-gmp/mini-gmp.o vendor/plfit/gss.o vendor/plfit/hzeta.o vendor/plfit/kolmogorov.o vendor/plfit/lbfgs.o vendor/plfit/mt.o vendor/plfit/options.o vendor/plfit/platform.o vendor/plfit/plfit.o vendor/plfit/plfit_error.o vendor/plfit/rbinom.o vendor/plfit/sampling.o vendor/arpack/dgetv0.o vendor/arpack/dlaqrb.o vendor/arpack/dmout.o vendor/arpack/dnaitr.o vendor/arpack/dnapps.o vendor/arpack/dnaup2.o vendor/arpack/dnaupd.o vendor/arpack/dnconv.o vendor/arpack/dneigh.o vendor/arpack/dneupd.o vendor/arpack/dngets.o vendor/arpack/dsaitr.o vendor/arpack/dsapps.o vendor/arpack/dsaup2.o vendor/arpack/dsaupd.o vendor/arpack/dsconv.o vendor/arpack/dseigt.o vendor/arpack/dsesrt.o vendor/arpack/dseupd.o vendor/arpack/dsgets.o vendor/arpack/dsortc.o vendor/arpack/dsortr.o vendor/arpack/dstatn.o vendor/arpack/dstats.o vendor/arpack/dstqrb.o vendor/arpack/dvout.o vendor/arpack/ivout.o vendor/arpack/second.o vendor/arpack/wrap.o vendor/simpleraytracer/Color.o vendor/simpleraytracer/Light.o vendor/simpleraytracer/Point.o vendor/simpleraytracer/RIgraphRay.o vendor/simpleraytracer/Ray.o vendor/simpleraytracer/RayTracer.o vendor/simpleraytracer/RayVector.o vendor/simpleraytracer/Shape.o vendor/simpleraytracer/Sphere.o vendor/simpleraytracer/Triangle.o vendor/simpleraytracer/unit_limiter.o vendor/uuid/R.o vendor/uuid/clear.o vendor/uuid/compare.o vendor/uuid/copy.o vendor/uuid/gen_uuid.o vendor/uuid/isnull.o vendor/uuid/pack.o vendor/uuid/parse.o vendor/uuid/unpack.o vendor/uuid/unparse.o rinterface.o rinterface_extra.o rrandom.o lazyeval.o -L/mingw64/lib -lxml2 -liconv -lz -lws2_32 -lstdc++ -L/mingw64/lib -lglpk -lgmp -lgfortran -L/mingw64/lib -LC:/PROGRA~1/MIE74D~1/ROPEN~1/R-40~1.2/bin/x64 -lRblas -LC:/PROGRA~1/MIE74D~1/ROPEN~1/R-40~1.2/bin/x64 -lRlapack -LC:/a/w/1/s/vendor/extsoft/lib/x64 -LC:/a/w/1/s/vendor/extsoft/lib -LC:/PROGRA~1/MIE74D~1/ROPEN~1/R-40~1.2/bin/x64 -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/libgfortran.a(write.o):(.text$get_precision+0x156): undefined reference to `quadmath_snprintf'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/libgfortran.a(write.o):(.text$get_float_string+0x170): undefined reference to `quadmath_snprintf'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/libgfortran.a(write.o):(.text$get_float_string+0xa62): undefined reference to `quadmath_snprintf'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/libgfortran.a(write.o):(.text$get_float_string+0x165c): undefined reference to `quadmath_snprintf'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/libgfortran.a(write.o):(.text$get_float_string+0x173a): undefined reference to `quadmath_snprintf'
collect2.exe: error: ld returned 1 exit status
make: *** [C:/PROGRA~1/MIE74D~1/ROPEN~1/R-40~1.2/share/make/winshlib.mk:13: igraph.dll] Error 1
ERROR: compilation failed for package 'igraph'
* removing 'C:/Users/b420054/Documents/R/win-library/4.0/igraph'
Warning in install.packages :
  installation of package ‘igraph’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\b420054\AppData\Local\Temp\RtmpWCVcB1\downloaded_packages’

I am on Windows 10 and R.version gives:

> R.version
               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          4                           
minor          0.2                         
year           2020                        
month          06                          
day            22                          
svn rev        78730                       
language       R                           
version.string R version 4.0.2 (2020-06-22)
nickname       Taking Off Again           

I have used pacman to load the required installation packages:

pacman -Sy mingw-w64-{i686,x86_64}-glpk mingw-w64-{i686,x86_64}-libxml2 mingw-w64-{i686,x86_64}-gmp

I am not sure what exactly is going wrong, but I also can’t test it as I cannot find documentation on how to build packages for Microsoft R Open. Do we know that it’s supposed to be compatible with RTools 4.0 distributed by CRAN?

Note that Microsoft R Open is no longer supported, and the MRAN website will be shut down on July 1st: https://mran.microsoft.com/ Thus it makes no sense for us to try to support this R distribution, or try to debug this issue.

I assume what you are really looking for is using a BLAS/LAPACK implementation with better performance.

I would suggest looking into using R from Conda-Forge, which does provide R with various BLAS/LAPACK backends, including OpenBLAS and the MKL. See e.g. here: Conda install r-essentials with MKL - Stack Overflow I just tried on macOS and even by default (i.e. without the complete setup described in that SO answer) I get an R linked to OpenBLAS, which is said to be competitive with the MKL. Conda-Forge also supplies igraph.

Thank you, appreciate the reply. Good points made, especially on MRAN.

In the end I managed to get igraph 1.4.1 compiled after reinstalling RTools and the required packages using pacman.

1 Like

Thanks for confirming that it worked! Which RTools did you use? RTools 4.0 from RTools: Toolchains for building R and R packages from source on Windows ?

Yes, I used that RTools installation.

Could I trouble you to ask for the packages you reinstalled and the RTools version you used as I am seeing the same error on Windows 10 with Open R 4.0.2.
I ran

pacman -Sy mingw-w64-{i686,x86_64}-glpk
pacman -Sy mingw-w64-{i686,x86_64}-libxml2

So I’m wondering whether I’ve missed a package or if there’s an issue with my RTools

When compiling from sources, make sure that you have C, C++ and Fortran compilers, as well as development packages for glpk and libxml2. On Debian/Ubuntu, use apt install libglpk-dev libxml2-dev. On Fedora, use yum install glpk-devel libxml2-devel.