# Error while building rigraph under Win10

**URL:** <https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321>\
**Category:** Installation\
**Created:** [3 July 2020 15:13 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321 "2020-07-03T15:13:01Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamGG](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/samgg/32/293_2.png) [@SamGG](https://igraph.discourse.group/u/SamGG)\
**Post date:** [3 July 2020 15:13 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/1 "2020-07-03T15:13:02Z")

</div>

Hi,  
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.  
Best.

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

```

---

<div class="post-metadata">

**Author:** ![vtraag](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/vtraag/32/38_2.png) [@vtraag](https://igraph.discourse.group/u/vtraag)\
**Post date:** [3 July 2020 20:52 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/2 "2020-07-03T20:52:24Z")

</div>

Could provide somewhat more details about how you downloaded/cloned the repository? There are some instructions in [`CONTRIBUTING.md`](https://github.com/igraph/rigraph/blob/dev/CONTRIBUTING.md) 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?

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [3 July 2020 20:53 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/3 "2020-07-03T20:53:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vtraag](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/vtraag/32/38_2.png) [@vtraag](https://igraph.discourse.group/u/vtraag)\
**Post date:** [3 July 2020 20:56 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/4 "2020-07-03T20:56:35Z")

</div>

> [@tamas](#):
>
> you have recently added the definitions of the Leiden algorithm in `functions.def` - maybe something is wrong there?

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 [Added the Leiden algorithm by vtraag · Pull Request #399 · igraph/rigraph · GitHub](https://github.com/igraph/rigraph/pull/399).

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [3 July 2020 20:59 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/5 "2020-07-03T20:59:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [3 July 2020 21:03 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/6 "2020-07-03T21:03:34Z")

</div>

[This commit](https://github.com/igraph/igraph/commit/42a1ca18) 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"`.

---

<div class="post-metadata">

**Author:** ![vtraag](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/vtraag/32/38_2.png) [@vtraag](https://igraph.discourse.group/u/vtraag)\
**Post date:** [3 July 2020 21:15 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/7 "2020-07-03T21:15:46Z")

</div>

> [@tamas](#):
>
> 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!

---

<div class="post-metadata">

**Author:** ![SamGG](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/samgg/32/293_2.png) [@SamGG](https://igraph.discourse.group/u/SamGG)\
**Post date:** [3 July 2020 21:34 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/8 "2020-07-03T21:34:42Z")

</div>

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

```auto
Traceback (most recent call last):
  File "cigraph/tools/stimulus.py", line 1488, in <module>
    main()
  File "cigraph/tools/stimulus.py", line 203, in main
    cg.generate(inputs, outputs[l])
  File "cigraph/tools/stimulus.py", 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 [https://github.com/vtraag/rigraph/tree/feature/leiden](https://github.com/vtraag/rigraph/tree/feature/leiden). How to generate it?

---

<div class="post-metadata">

**Author:** ![SamGG](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/samgg/32/293_2.png) [@SamGG](https://igraph.discourse.group/u/SamGG)\
**Post date:** [3 July 2020 21:45 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/9 "2020-07-03T21:45:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![SamGG](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/samgg/32/293_2.png) [@SamGG](https://igraph.discourse.group/u/SamGG)\
**Post date:** [5 July 2020 19:14 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/10 "2020-07-05T19:14:55Z")

</div>

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.

```auto
$ 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'

```

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [6 July 2020 09:19 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/11 "2020-07-06T09:19:02Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [6 July 2020 11:09 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/12 "2020-07-06T11:09:54Z")

</div>

> [@tamas](#):
>
> I think that’s only used for 3D graph plotting (not sure how)

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:

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

```

 ![image](https://global.discourse-cdn.com/free1/uploads/igraph/original/1X/6357b4ab9724c45f3ceb009f7a903e59800f4a64.png)

---

<div class="post-metadata">

**Author:** ![SamGG](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/samgg/32/293_2.png) [@SamGG](https://igraph.discourse.group/u/SamGG)\
**Post date:** [6 July 2020 14:04 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/13 "2020-07-06T14:04:07Z")

</div>

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](https://github.com/igraph/rigraph/blob/a14fc50abf9bf3ae17b870ccbc21f88d0eefed6e/R/plot.shapes.R#L944) file.  
IMHO, there should be not optional stuff. I feel compilation already difficult enough for noob. like me

---

<div class="post-metadata">

**Author:** ![SamGG](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/samgg/32/293_2.png) [@SamGG](https://igraph.discourse.group/u/SamGG)\
**Post date:** [6 July 2020 14:35 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/14 "2020-07-06T14:35:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vtraag](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/vtraag/32/38_2.png) [@vtraag](https://igraph.discourse.group/u/vtraag)\
**Post date:** [6 July 2020 15:29 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/15 "2020-07-06T15:29:43Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![SamGG](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/samgg/32/293_2.png) [@SamGG](https://igraph.discourse.group/u/SamGG)\
**Post date:** [6 July 2020 16:14 UTC](https://igraph.discourse.group/t/error-while-building-rigraph-under-win10/321/16 "2020-07-06T16:14:33Z")

</div>

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.
