# Packaging the igraph C library

# Overview

Rigraphlib builds the igraph static library for use in R/Bioconductor packages. This is primarily intended for R packages that wrap other C/C++ libraries that depend on the igraph C library and cannot easily be modified to use the usual igraph R package. By vendoring in the source code, we also reduce our susceptibility to out-of-release-schedule changes in results due to igraph updates. This also allows developers to access functionality that might yet not be available from the R bindings.

Currently, this package contains version 1.0.0 of the C igraph library.

# Quick start

Downstream package developers can use Rigraphlib by adding:

    Imports: Rigraphlib

to their package `DESCRIPTION`, and setting:

    RIGRAPH_FLAGS=$(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript" -e 'Rigraphlib::pkgconfig("PKG_CPPFLAGS")')
    PKG_CPPFLAGS=$(RIGRAPH_FLAGS)
    RIGRAPH_LIBS=$(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript" -e 'Rigraphlib::pkgconfig("PKG_LIBS")')
    PKG_LIBS=$(RIGRAPH_LIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

in their `src/Makevars`. We use R’s own BLAS and LAPACK libraries to avoid redundant recompilation of igraph’s vendored copies.

# For R administrators

If the `RIGRAPHLIB_PKG_CPPFLAGS` environment is set, its contents will be printed by `pkgconfig("PKG_CPPFLAGS")`. Similarly, if the `RIGRAPHLIB_PKG_LIBS` environment is set, its contents will be printed by `pkgconfig("PKG_LIBS")`. These take precedence over any other options or environment variables.

If the `RIGRAPHLIB_USE_SYSTEM_LIBRARY` environment variable is set to 1 during or after installation of Rigraphlib, `pkgconfig()` will instead call `pkg-config igraph` to link to the system igraph installation. In addition, if this environment variable is set during Rigraphlib installation, the vendored source code will not be compiled unless the `RIGRAPHLIB_FORCE_BUILD` environment variable is set to 1.

In both cases, the version of igraph referenced by any custom flags should be consistent with the version of the vendored igraph source. This ensures that downstream packages based on Rigraphlib will build and run as expected.

# Session information

    sessionInfo()

    ## R version 4.5.2 (2025-10-31)
    ## Platform: x86_64-pc-linux-gnu
    ## Running under: Ubuntu 24.04.3 LTS
    ##
    ## Matrix products: default
    ## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
    ## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
    ##
    ## locale:
    ##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    ##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C
    ##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
    ##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
    ##  [9] LC_ADDRESS=C               LC_TELEPHONE=C
    ## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
    ##
    ## time zone: Etc/UTC
    ## tzcode source: system (glibc)
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ## [1] knitr_1.50       BiocStyle_2.39.0
    ##
    ## loaded via a namespace (and not attached):
    ##  [1] digest_0.6.39       R6_2.6.1            fastmap_1.2.0
    ##  [4] xfun_0.54           maketools_1.3.2     cachem_1.1.0
    ##  [7] htmltools_0.5.9     rmarkdown_2.30      buildtools_1.0.0
    ## [10] lifecycle_1.0.4     cli_3.6.5           sass_0.4.10
    ## [13] jquerylib_0.1.4     compiler_4.5.2      sys_3.4.3
    ## [16] tools_4.5.2         evaluate_1.0.5      bslib_0.9.0
    ## [19] yaml_2.3.11         BiocManager_1.30.27 Rigraphlib_1.3.2
    ## [22] jsonlite_2.0.0      rlang_1.1.6