<p>Please see the Rcpp vignette <a href="https://cloud.r-project.org/web/packages/Rcpp/vignettes/Rcpp-libraries.pdf" rel="nofollow noreferrer">Rcpp libraries</a> -- which is also this <a href="https://arxiv.org/abs/1911.06416" rel="nofollow noreferrer">arXiv paper</a>.</p>
<p>There are many examples among the 2400+ CRAN packages using <code>Rcpp</code>.  My hunch would probably be to look at what I contributed to the <code>nloptr</code> package -- even though that is a more complicated scheme where we allow use <em>either</em> a system library if present (could be the case with <code>fftw3</code> too) <em>or</em> downloand and build.</p>
<p>Rcpp has been used <em>a lot</em> to build such glue.  The most common, and simplest , approach is to look for <code>pkg-config</code> and query it for headers and libraries.  Please give that a shot (with some looking around CRAN or GitHub for examples).</p>
<p><em>Edit:</em> There is also an (old) <code>fftw3</code> package by Gabor <a href="https://github.com/MangoTheCat/fftw3" rel="nofollow noreferrer">at his previous employer's GitHub org</a> as well as another <a href="https://cran.r-project.org/package=fftwtools" rel="nofollow noreferrer">CRAN package <code>fftwtools</code></a> (which, if memory served, I helped once too but I don't recall now what for).</p>
Linking to fftw3.h in C++ source file for R package
<p>I have some C++ code that I intend to export into my r package using Rcpp. However, this code links to <a href="https://www.fftw.org/" rel="nofollow noreferrer">fftw3</a> via</p>
<pre><code>#include &lt;fftw3.h&gt;
</code></pre>
<p>at the top of the file. When I try to compile this code, I unsurprisingly get the error</p>
<pre><code>fatal error: 'fftw3.h' file not found
</code></pre>
<p>What is the proper way to link to this file so that it will be available upon compilation of my package? I know that a Makevars file can generally be used to link to system libraries but since this library is external I'm not sure what to do.</p>
<p>Thanks,</p>
<p>Eric.</p>