Greetings and Salutations All,

I'm trying to add structure to the src folder since the amount of files I have 
residing in the src directory could be better organized. Note: These files are 
made using RcppArmadillo.

E.g.

I'm looking to go from:

src/
    |-> main.cpp
    |-> testA.cpp
    |-> testA.h
    |-> testB.cpp
    |-> testB.h

To a structure like:

src/
   |-> main.cpp
   |-> A
       |-> testA.cpp
       |-> testA.h
   |-> B
       |-> testB.cpp
       |-> testB.h

Each file has a function:
main.cpp => testfunction(x)
testA.cpp => testfunctionA(x)
testB.cpp => testfunctionB(x)

To illustrate the issue, I have two repositories

SrcDir: https://github.com/coatless/header_cpp_subdir_code
SubdirSrc: https://github.com/coatless/header_cpp_code

If I compile without trying to change the folder structure, the package is made 
and is able to use without issue.

However, when I attempt to change the folder structure, I was getting a 
compiler error that identifies with a linking issue:

main.o:main.cpp:(.text+0x650a): undefined reference to 
`testfunctionA(arma::Col<double> const&)'

I looked at CRANs documentation for a suggested fix and ended up trying to 
ensure a link by using the makevars file (see: 
http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Using-Makevars)

I made the following changes:

The Makevars file update seemed to work as the package then compiled.
(Exact changes to Makevars.win: 
https://github.com/coatless/header_cpp_subdir_code/blob/master/src/Makevars.win 
)

Herein lies the issues:


1.        Any files I've written in the subdirectories are no longer exported 
to RcppExport.cpp even though they have a // [[Rcpp::export]] tag preceding the 
function declaration.

2.       When I try to call the function in main.cpp (testfunction(x)), I 
receive:

testfunction(2^(1:5))

Error in .Call("SubdirSrc_testfunction", PACKAGE = "SubdirSrc", x) :

  "SubdirSrc_testfunction" not available for .Call() for package "SubdirSrc"



Any suggestions would be appreciated.

Sincerely,

JJB
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to