Skip to content

Rcpp and Rust functions in same package #406

Open
@Close-your-eyes

Description

@Close-your-eyes

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’

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions