Rcpp: Cannot include the header.

Created on 2 Jul 2020  Â·  4Comments  Â·  Source: RcppCore/Rcpp

Hi. I looked through StackOverflow but cannot find what I want.
I am including 2 libraries into the package: ArrayFire and flashlight. The first one loads fine and I can build it. However, while loading the second the one it throws an error and indicates to embedding.h as far as I understand.

==> Rcpp::compileAttributes()

* Updated src/RcppExports.cpp
* Updated R/RcppExports.R

==> devtools::document(roclets = c('rd', 'collate', 'namespace', 'vignette'))

Updating flashlight documentation
Loading flashlight
Re-compiling flashlight
─  installing *source* package ‘flashlight’ ...
   ** using staged installation
   ** libs
   g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/home/turgut/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include'    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c RcppExports.cpp -o RcppExports.o
   g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o flashlight.so RcppExports.o Variable.o rcpp_hello_world.o -L/usr/lib/R/lib -lR
   installing to /tmp/RtmpWr0ysJ/devtools_install_17607ce5f54f/00LOCK-flashlight/00new/flashlight/libs
   ** checking absolute paths in shared objects and dynamic libraries
─  DONE (flashlight)
Error in dyn.load(dllfile) : 
  unable to load shared object '/home/turgut/Documents/flashlight/src/flashlight.so':
  /home/turgut/Documents/flashlight/src/flashlight.so: undefined symbol: _ZTIN2fl9EmbeddingE
Calls: suppressPackageStartupMessages ... <Anonymous> -> load_dll -> library.dynam2 -> dyn.load
Execution halted

Exited with status 1.

This is my cpp file:

#include <flashlight/flashlight.h>
using namespace fl;

R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so

locale:
 [1] LC_CTYPE=en_US.UTF-8    LC_NUMERIC=C            LC_TIME=az_AZ           LC_COLLATE=en_US.UTF-8 
 [5] LC_MONETARY=az_AZ       LC_MESSAGES=en_US.UTF-8 LC_PAPER=az_AZ          LC_NAME=C              
 [9] LC_ADDRESS=C            LC_TELEPHONE=C          LC_MEASUREMENT=az_AZ    LC_IDENTIFICATION=C    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2    Rcpp_1.0.4.6  
CXX_STD = CXX11
PKG_CPPFLAGS = -I../inst/include

Most helpful comment

My pleasure. (BTW You can close too as the originator.)

Libraries, esp larger ones, are tough. I wrote a short paper recently that the next Rcpp will have as a vignette too. See here for more: https://arxiv.org/abs/1911.06416

All 4 comments

Well:

edd@rob:~$ c++filt _ZTIN2fl9EmbeddingE
typeinfo for fl::Embedding
edd@rob:~$ 

What flashlight simply is _not_ a header-only library?

A casual look at https://github.com/facebookresearch/flashlight/blob/716d1b0913be1c26e446ed37450a5081c371a749/flashlight/nn/modules/Embedding.cpp would support that line of thinking.

In short I think you need to rethink how you set your package up. This isn't Rcpp's fault so I suggest we close this.

Thanks so much for reply. Please, close this issue.

My pleasure. (BTW You can close too as the originator.)

Libraries, esp larger ones, are tough. I wrote a short paper recently that the next Rcpp will have as a vignette too. See here for more: https://arxiv.org/abs/1911.06416

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhiruiwang picture zhiruiwang  Â·  6Comments

kevinushey picture kevinushey  Â·  6Comments

helmingstay picture helmingstay  Â·  4Comments

karthik2527 picture karthik2527  Â·  4Comments

PeteHaitch picture PeteHaitch  Â·  6Comments