This package is my attempt to understand debugging compiled code. I'm having difficulty debugging segmentation faults in R-TDA. Some outstanding questions :
- How is the compiled code in R-TDA actually compiled. There isn't a Makefile or configure file?
- Why can't I get useful debugging information in _TDA_Kde()?
- How does R mangle (see Rcppexports.cpp) the functions in the src code?
- How does ~/.R/Makevars control compilation flags.
Steps :
install.packages("devtools")
devtools::install_github("klutometis/roxygen")
If you've cloned this repo:
library(devtools); library(roxygen2)
document()
To create a raw package (NOT what you'll do if you've cloned this repo):
- load
devtools
androxygen2
create("debug.Compiled.R.Packages")
# Create directordocument()
# Generates man and NAMESPACEsetwd("..")
;install("debug.Compiled.R.Packages")
a) Evidently, MUST have all code wrapped within functions. The files get sourced.usethis::use_rcpp()
a) Creates src b) Adds Rcpp to LinkingTo and Imports in DESCRIPTION c) Creates src/.gitignore so that compiled code doesn't accidently get committed to git repodevtools::load_all()
per ref 4 this is dangerous
On Compiling :
- Note that
package/src/Makevars
takes precedence over~/.R/Makevars
. This is largely why I'm having difficulty debugging R-TDA - R magically compiles code into shared library
On Namespace :
- Can selectively export functions to users, hold back other functions for internal use.
search()
provides a list of search paths.library()
loads the package into memory and then adds it to search path. a) Never use in a package, only in external scripts calling the package