Skip to content

Commit c7eaf51

Browse files
committed
add 'compileAttributes() twice' to Rcpp-FAQ (closes #745)
1 parent 85f5c3d commit c7eaf51

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

ChangeLog

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
2017-09-21 Dirk Eddelbuettel <[email protected]>
2+
3+
* vignettes/Rcpp-FAQ.Rmd (Rcpp): Add entry for 'symbols not found' error
4+
requiring two runs of compileAttributes
5+
16
2017-09-20 James J Balamuta <[email protected]>
27

3-
* DESCRIPTION (Version, Date): Roll minor version
4-
* vignettes/jss.bst: Removed
5-
* vignettes/rcpp-docs.cls: idem
8+
* vignettes/rcpp-docs.cls: Removed
69

710
2017-09-20 Dirk Eddelbuettel <[email protected]>
811

inst/NEWS.Rd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
addressing issue \ghit{682}).
2525
\item Added a new vignette \sQuote{Rcpp-introduction} based on new PeerJ
2626
preprint, renamed existing introduction to \sQuote{Rcpp-jss-2011}.
27-
\item Transitioned all vignettes to the pinp RMarkdown template
27+
\item Transitioned all vignettes to the 'pinp' RMarkdown template
2828
(James Balamuta and Dirk Eddelbuettel in \ghpr{755} addressing
2929
issue \ghit{604}).
30+
\item Added an entry on running `compileAttributes()` twice to the
31+
Rcpp-FAQ (\ghit{#745}).
3032
}
3133
}
3234
}

vignettes/Rcpp-FAQ.Rmd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,4 +1684,29 @@ sort(x)
16841684
rcpp_sort(x)
16851685
```
16861686

1687+
## Package building fails with 'symbols not found'
1688+
1689+
R 3.4.0 and later strongly encourage registering dynamically loadable
1690+
symbols. In the stronger form (where `.registration=TRUE` is added to the
1691+
`useDynLib()` statement in `NAMESPACE`), only registered symbols can be
1692+
loaded. This is fully supported by Rcpp 0.12.12 and later, and the required code
1693+
is added to `src/RcppExports.cpp`.
1694+
1695+
However, the transition from the previously generated file `src/RcppExports.cpp`
1696+
to the new one may require running `compileAttributes()` twice (which does not
1697+
happen when, _e.g., devrtools is used). When `Rcpp::compileAttributes()` is
1698+
called, it also calls `tools::package_native_routine_registration_skeleton()`,
1699+
which crawls through usages of `.Call()` in the `R/` source files of the package to
1700+
figure out what routines need to be registered. If an older `RcppExports.R` file
1701+
is discovered, its out-of-date symbol names get picked up, and registration
1702+
rules for those symbols get written as well. This will register more symbols for
1703+
the package than are actually defined, leading to an error. This point has been
1704+
discussed at some length both in the GitHub issue tickes, on StackOverflow and
1705+
elsewhere.
1706+
1707+
So if your autogenerated file fails, and a `symbols not found` error is reported
1708+
by the linker, consider running `compileAttributes()` twice. Deleting
1709+
`R/RcppExports.R` and `src/RcppExports.cpp` may also work.
1710+
1711+
16871712
\newpage

0 commit comments

Comments
 (0)