You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I tried to add functions in Rcpp and Rust to a package. When adding them separately, compilation works fine. In combination though, compilation fails. Is that expectable? What do I need to consider?
Here is the error message when running devtools::document or rextendr::document (igsc is the package's name):
── R CMD INSTALL ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─ installing source package ‘igsc’ ... (412ms)
** using staged installation
** libs
using C compiler: ‘Apple clang version 11.0.3 (clang-1103.0.32.29)’
using C++ compiler: ‘Apple clang version 11.0.3 (clang-1103.0.32.29)’
using SDK: ‘MacOSX10.15.sdk’
rm -Rf igsc.so ./rust/target/release/libigsc.a RcppExports.o entrypoint.o proc_gtf_attr.o
clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c RcppExports.cpp -o RcppExports.o
clang -arch x86_64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c entrypoint.c -o entrypoint.o
clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c proc_gtf_attr.cpp -o proc_gtf_attr.o
In some environments, ~/.cargo/bin might not be included in PATH, so we need
to set it here to ensure cargo can be invoked. It is appended to PATH and
therefore is only used if cargo is absent from the user's PATH.
if [ "true" != "true" ]; then
export CARGO_HOME=/Users/vonskopnik/Documents/R_packages/igsc/src/.cargo;
fi &&
export PATH="/usr/local/bin:/Users/vonskopnik/.cargo/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Little Snitch.app/Contents/Components:/opt/X11/bin:/Users/vonskopnik/Applications/quarto/bin:/Library/TeX/texbin:/usr/texbin:/Applications/RStudio.app/Contents/Resources/app/quarto/bin:/Applications/RStudio.app/Contents/Resources/app/bin/postback:/Users/vonskopnik/.cargo/bin" &&
cargo build --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target
Finished release profile [optimized] target(s) in 0.11s
if [ "true" != "true" ]; then
rm -Rf /Users/vonskopnik/Documents/R_packages/igsc/src/.cargo &&
rm -Rf ./rust/target/release/build;
fi
clang++ -arch x86_64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/x86_64/lib -o igsc.so RcppExports.o entrypoint.o proc_gtf_attr.o -L./rust/target/release -ligsc -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
duplicate symbol '_R_init_igsc' in:
RcppExports.o
entrypoint.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [igsc.so] Error 1
ERROR: compilation failed for package ‘igsc’
The text was updated successfully, but these errors were encountered:
@CGMossa for my edification, what is that small problem? To me it looks like Rcpp is trying to export a symbol with the same name that extendr is also exporting
I would not say it is that small. Currently, extendr generates the exports that are registered, IIRC, with R_registerRoutines. And we overwrite entrypoint.c. If I am correct, exports are not additive, and you can only have one function named after the packages exposed from the binary. Right now all of this is overtaken by extendr. One solution -- if you desperately need Rcpp there -- could be to try to register Rcpp code as FFI in Rust and then export this Rust function using extendr facilities. This will, however, require some non-trivial changes to makefiles.
Hello, I tried to add functions in Rcpp and Rust to a package. When adding them separately, compilation works fine. In combination though, compilation fails. Is that expectable? What do I need to consider?
Here is the error message when running devtools::document or rextendr::document (igsc is the package's name):
── R CMD INSTALL ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─ installing source package ‘igsc’ ... (412ms)
** using staged installation
** libs
using C compiler: ‘Apple clang version 11.0.3 (clang-1103.0.32.29)’
using C++ compiler: ‘Apple clang version 11.0.3 (clang-1103.0.32.29)’
using SDK: ‘MacOSX10.15.sdk’
rm -Rf igsc.so ./rust/target/release/libigsc.a RcppExports.o entrypoint.o proc_gtf_attr.o
clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c RcppExports.cpp -o RcppExports.o
clang -arch x86_64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c entrypoint.c -o entrypoint.o
clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c proc_gtf_attr.cpp -o proc_gtf_attr.o
In some environments, ~/.cargo/bin might not be included in PATH, so we need
to set it here to ensure cargo can be invoked. It is appended to PATH and
therefore is only used if cargo is absent from the user's PATH.
if [ "true" != "true" ]; then
export CARGO_HOME=/Users/vonskopnik/Documents/R_packages/igsc/src/.cargo;
fi &&
export PATH="/usr/local/bin:/Users/vonskopnik/.cargo/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Little Snitch.app/Contents/Components:/opt/X11/bin:/Users/vonskopnik/Applications/quarto/bin:/Library/TeX/texbin:/usr/texbin:/Applications/RStudio.app/Contents/Resources/app/quarto/bin:/Applications/RStudio.app/Contents/Resources/app/bin/postback:/Users/vonskopnik/.cargo/bin" &&
cargo build --lib --release --manifest-path=./rust/Cargo.toml --target-dir ./rust/target
Finished
release
profile [optimized] target(s) in 0.11sif [ "true" != "true" ]; then
rm -Rf /Users/vonskopnik/Documents/R_packages/igsc/src/.cargo &&
rm -Rf ./rust/target/release/build;
fi
clang++ -arch x86_64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/x86_64/lib -o igsc.so RcppExports.o entrypoint.o proc_gtf_attr.o -L./rust/target/release -ligsc -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
duplicate symbol '_R_init_igsc' in:
RcppExports.o
entrypoint.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [igsc.so] Error 1
ERROR: compilation failed for package ‘igsc’
The text was updated successfully, but these errors were encountered: