Error while building rigraph under Win10

Thanks for the current dev of @vtraag integrating Leiden and R. Win10 being my workhorse, I am using the latest MSYS2, not the one of Rtools. Here is the error I am facing. Any idea is welcome. No problem to compile cigraph which is needed, but I got this error when executing “make” in the rigraph folder.

$ cigraph/tools/ \
>            -f cigraph/interfaces/functions.def \
>            -i tools/stimulus/ \
>            -o R/auto.R \
>            -t tools/stimulus/types-R.def \
>            -l RR
Traceback (most recent call last):
  File "cigraph/tools/", line 1487, in <module>
  File "cigraph/tools/", line 201, in main
    cg=cl(functions, types)
  File "cigraph/tools/", line 335, in __init__
    CodeGenerator.__init__(self, func, types)
  File "cigraph/tools/", line 223, in __init__
  File "cigraph/tools/", line 118, in parse
  File "cigraph/tools/", line 77, in token
    while line[-1]=="\\":
IndexError: string index out of range

Could provide somewhat more details about how you downloaded/cloned the repository? There are some instructions in you could follow.

One potential problem might be the line endings, I think it should all have only Linux style line endings (i.e. only \n) but it might be that you have all Windows line endings (i.e. \r\n). Could you perhaps check that?

This message comes from the Python-based interface generator that generates some parts of the source code of the R interface based on a function definiton file (functions.def). My guess would be that there is a syntax error somewhere in functions.def. @vtraag, you have recently added the definitions of the Leiden algorithm in functions.def - maybe something is wrong there?

I’ll try to poke around a bit.

No, it compiles correctly under Linux.

It might also be a problem with the Python version, although I doubt that is the problem.

To be sure, I believe the OP is trying to build from my PR

Line endings are indeed the issue; I converted my functions.def to DOS line endings with unix2dos and I got the same error.

1 Like

This commit fixes the problem for me on my machine. (macOS, but with Windows line ending). The “universal newline mode” in Python basically converts all newlines to the Unix format on-the-fly, this is what we trigger in this commit with "rU".


Didn’t know about that, very useful!

Thanks for “rU”, it solves the issue. Next one is:

Traceback (most recent call last):
  File "cigraph/tools/", line 1488, in <module>
  File "cigraph/tools/", line 203, in main
    cg.generate(inputs, outputs[l])
  File "cigraph/tools/", line 234, in generate
    out=open(output, "w")
IOError: [Errno 2] No such file or directory: 'src/rinterface.c'
make: *** [Makefile:108 : src/rinterface.c] Erreur 1

There is no src folder in How to generate it?

I did mkdir src on command line. It seems that there is a “mkdir -p src” command missing in the Makefile for the target src/interface.c before the running the stimulus command.

Finally, I am ending up with the following error. I don’t if I should remove the code of R_igraph_getsphere from rinterface.c or do some other trick. Any help appreciated.

$ R CMD INSTALL . --build --multiarch
Warning: unknown option '--multiarch'
* installing to library 'C:/opt/R/R-4.0.0/library'
* installing *source* package 'igraph' ...
** using staged installation
** libs
C:/opt/rtools40/mingw64/bin/gcc -shared -s -static-libgcc -o igraph.dll tmp.def dgetv0.o dlaqrb.o dmout.o dnaitr.o dnapps.o dnaup2.o dnaupd.o dnconv.o dneigh.o dneupd.o dngets.o dsaitr.o dsapps.o dsaup2.o dsaupd.o dsconv.o dseigt.o dsesrt.o dseupd.o dsgets.o dsortc.o dsortr.o dstatn.o dstats.o dstqrb.o dvout.o ivout.o second.o wrap.o uuid/R.o uuid/clear.o uuid/compare.o uuid/copy.o uuid/gen_uuid.o uuid/isnull.o uuid/pack.o uuid/parse.o uuid/unpack.o uuid/unparse.o rinterface.o rinterface_extra.o lazyeval.o -L/mingw64/lib -ligraph -L/lib -lxml2 -liconv -lz -lws2_32 -L/lib -lglpk -lgmp -L/lib -LC:/opt/R/R-4.0.0/bin/x64 -lRblas -LC:/opt/R/R-4.0.0/bin/x64 -lRlapack -lgfortran -lm -lquadmath -LC:/opt/R/R-4.0.0/bin/x64 -lR
C:/opt/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: rinterface.o:rinterface.c:(.rdata+0x3dd0): undefined reference to `R_igraph_getsphere'
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'igraph'
* removing 'C:/opt/R/R-4.0.0/library/igraph'
* restoring previous 'C:/opt/R/R-4.0.0/library/igraph'

R_igraph_getsphere is in the optional/simpleraytracer folder in the repo of igraph (the C version). I think that’s only used for 3D graph plotting (not sure how), so if you don’t need this, you can comment it out for the time being to make things compile.

It is used in 2D graph plotting, to generate a certain vertex shape (which looks like shaded 3D spheres). Basically it generates a 3D sphere image at any resolution you want.

Try this:

plot(make_ring(5), vertex.shape='sphere')

Thanks for the feedback. I investigated a little bit.
Although getsphere C code is an optional directory, this code is really used in a R function of plot.shapes.R file.
IMHO, there should be not optional stuff. I feel compilation already difficult enough for noob. like me

Reading the Rigraph Makefile, I think the content of the optional directory is copied to the src directory. In my case, it seems not to be done… But I don’t know how to debug this part of the Makefile. Currently, I commented the definition in the init.c file.

If I were you, I would clean the entire repository (using git clean -fdx and run make afresh. The Makefile might be a bit fragile, and if you encountered errors earlier, some to the commands might not have executed properly. The creation of the src directory should have also been done in the Makefile.

Thanks all for your help. I have no more time to work on that during the next few weeks. I will come back later. Keep safe.