I am hoping this just relates to some aspect of organizing files that @perrydv can help me with at some point (this is not urgent).
Two problem cases:
- In the TBB work I created a C++ function
getNumThreads in utils.h. This works fine when compiling on the fly, but when I try to create a package (with nCompile(...,package = TRUE) or writePackage, I get this:
g++ -std=gnu++17 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -o foo1.so R_interfaces_c_.o RcppExports.o nClass_1_c_.o rcpp_hello_world.o -L/usr/lib/R/lib -lR
/usr/bin/ld: RcppExports.o: in function `getNumThreads(double)':
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-24.04/4.5/nCompiler/include/nCompiler/utils.h:1: multiple definition of `getNumThreads(double)'; R_interfaces_c_.o:/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-24.04/4.5/nCompiler/include/nCompiler/utils.h:1: first defined here
/usr/bin/ld: nClass_1_c_.o: in function `getNumThreads(double)':
/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-24.04/4.5/nCompiler/include/nCompiler/utils.h:1: multiple definition of `getNumThreads(double)'; R_interfaces_c_.o:/accounts/vis/paciorek/R/x86_64-pc-linux-gnu-library-ubuntu-24.04/4.5/nCompiler/include/nCompiler/utils.h:1: first defined here
collect2: error: ld returned 1 exit status
- In the messaging work I created functions like
nStop in utils.h. Again it's fine when compiling on the fly, but when creating a package:
nFun_2_c_.cpp: In function ‘void nFun_2(Eigen::Tensor<double, 1>)’:
nFun_2_c_.cpp:27:1: error: ‘_nCompiler_global_output’ was not declared in this scope
27 | _nCompiler_global_output << "problem: "<<y<<" "<<x+y; nStop(_nCompiler_global_output);
| ^~~~~~~~~~~~~~~~~~~~~~~~
nFun_2_c_.cpp:27:55: error: ‘nStop’ was not declared in this scope; did you mean ‘nStep’?
27 | _nCompiler_global_output << "problem: "<<y<<" "<<x+y; nStop(_nCompiler_global_output);
| ^~~~~
| nStep
I am hoping this just relates to some aspect of organizing files that @perrydv can help me with at some point (this is not urgent).
Two problem cases:
getNumThreadsinutils.h. This works fine when compiling on the fly, but when I try to create a package (withnCompile(...,package = TRUE)orwritePackage, I get this:nStopinutils.h. Again it's fine when compiling on the fly, but when creating a package: