This package is my attempt to understand debugging compiled code. I'm having difficulty debugging segmentation faults in R-TDA. Some outstanding questions : 1. How is the compiled code in R-TDA actually compiled. There isn't a Makefile or configure file? 2. Why can't I get useful debugging information in _TDA_Kde()? 3. How does R mangle (see Rcppexports.cpp) the functions in the src code? 4. How does ~/.R/Makevars control compilation flags.
Steps :
1. install.packages("devtools")
2. devtools::install_github("klutometis/roxygen")
If you've cloned this repo:
1. library(devtools); library(roxygen2)
2. document()
To create a raw package (NOT what you'll do if you've cloned this repo):
1. load devtools
and roxygen2
2. create("debug.Compiled.R.Packages")
# Create director
3. document()
# Generates man and NAMESPACE
4. setwd("..")
; install("debug.Compiled.R.Packages")
a) Evidently, MUST have all code wrapped within functions. The files get sourced.
5. 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 repo
6. devtools::load_all()
per ref 4 this is dangerous
On Compiling :
1. Note that package/src/Makevars
takes precedence over ~/.R/Makevars
. This is
largely why I'm having difficulty debugging R-TDA
2. R magically compiles code into shared library
On Namespace :
1. Can selectively export functions to users, hold back other functions for
internal use.
2. search()
provides a list of search paths.
3. 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.