Linking libraries in R


Would be anyone ready to suggest any options how to link C++ library to C++ package in R studio. I have this igraph library which i need for integration of algorithm(igraph C,C++ core). I have tried to link it with makevars.

This is the run statement from VS code:

g++ -std=c++17 -O3 -march=native -DNDEBUG -I/usr/local/include/igraph -Iinclude -L/usr/local/lib -o a.out main.cpp -ligraph -lm -lstdc++ -lgomp -lpthread

And this is directory path to static library:



I really need advice, how to do it or some help with it because this is my diploma thesis.

  1. How can i link library in R studio, static, dynamic and then in description folders is comand linkingTo with which i have included BoostHeaders i can give commands to makevars, but it would be really nice if someone could explain me one or more solutions that would work.

I would ask for a explanation of solution that would help me and/or help writting makevars.

Compiling igraph specifically for use in R requires a more complicated setup. I am not entirely sure what you are trying to accomplish. If you just want to modify some of the code in igraph, it would probably be easiest to take the following approach:

  1. Clone the rigraph repository.
  2. Update the cigraph submodule to point to whatever code in the igraph C core that you want to change.
  3. You can then build and install the updated version of the R interface of igraph following the instructions here.

This assumes that you did not create any new functionality, or updated any arguments, but just made some changes to existing algorithms.

If you did make some changes, you will need to update some other relevant files. Much of the code for the R interface is auto-generated by a custom code generation tool called Stimulus. See here for a brief documentation of the format used by the code generation tools Stimulus. The files you will need to change then are

  1. The three YAML files in tools/stimulus/:
    a. functions-R.yaml
    b. types-RC.yaml
    c. types-RR.yaml
  2. The YAML file in the igraph C core interfaces directory:
    a. functions.yaml
    b. types.yaml
  3. Some functions require custom code instead of auto-generated code by Stimulus. If so, you should make changes in tools/stimulus/:

@tamas, is there anything here that I forgot? If so, feel free to edit. Perhaps we should also include this explanation in the rigraph repository in the