Hi, I am trying to wrap the Fasttext lib from Facebook on R. I have wrote a minimal code based on Rcpp.package.skeleton(module = TRUE) The C++ file compiles/works with sourceCpp() but it crashes when building a package. I have checked many D. Eddelbuettel to get a clue of what to do but no luck. I have already setup a Makevars file with a path to the include folder. The package source code is available there: https://github.com/pommedeterresautee/FastRText My Makevars: CXX_STD = CXX11 ROOT_INCLUDE = ../inst/include/ PKG_CPPFLAGS=-I$(ROOT_INCLUDE) The error I am seeing: ==> R CMD INSTALL --preclean --no-multiarch --with-keep.source FastRText ... Error: package or namespace load failed for ?FastRText? in dyn.load(file, DLLpath = DLLpath, ...): impossible de charger l'objet partag? '/home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so': /home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so: undefined symbol: _ZN8fasttext8FastTextC1Ev The full log is available there: https://github.com/pommedeterresautee/FastRText/issues/1 According to c++filt undefined symbol: _ZN8fasttext8FastTextC1Ev means -> fasttext::FastText::FastText() Has anyone an idea? Kind regards, Micha?l ________________ Micha?l BENESTY michael at benesty.fr Please do not print this e-mail unless you really need to.
[Rcpp-devel] Rcpp + Package -> undefined symbol
7 messages · Michaël BENESTY, Dirk Eddelbuettel, Qiang Kou +1 more
On 2 August 2017 at 20:22, Micha?l BENESTY wrote:
| Hi, | | I am trying to wrap the Fasttext lib from Facebook on R. | I have wrote a minimal code based on Rcpp.package.skeleton(module = TRUE) | | The C++ file compiles/works with sourceCpp() but it crashes when | building a package. | I have checked many D. Eddelbuettel to get a clue of what to do but no luck. | I have already setup a Makevars file with a path to the include folder. | | The package source code is available there: | https://github.com/pommedeterresautee/FastRText | | My Makevars: | CXX_STD = CXX11 | ROOT_INCLUDE = ../inst/include/ | PKG_CPPFLAGS=-I$(ROOT_INCLUDE) If this is a library then you need to __link__ to it as well. That is commonly done via PKG_LIBS=... and it may get you the additional problem of having to ensure users of your package have the fastText library installed. Dirk | | | The error I am seeing: | ==> R CMD INSTALL --preclean --no-multiarch --with-keep.source FastRText | ... | Error: package or namespace load failed for ?FastRText? in | dyn.load(file, DLLpath = DLLpath, ...): | impossible de charger l'objet partag? | '/home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so': | /home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so: | undefined symbol: _ZN8fasttext8FastTextC1Ev | | | The full log is available there: | https://github.com/pommedeterresautee/FastRText/issues/1 | | According to c++filt | undefined symbol: _ZN8fasttext8FastTextC1Ev means -> | fasttext::FastText::FastText() | | | Has anyone an idea? | | Kind regards, | Micha?l | ________________ | Micha?l BENESTY | michael at benesty.fr | Please do not print this e-mail unless you really need to. | _______________________________________________ | Rcpp-devel mailing list | Rcpp-devel at lists.r-forge.r-project.org | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
Thank you Dirk for this answer. The source code of Fasttext is already embedded in the package (it is the content of ../inst/include/ and is linked with PKG_CPPFLAGS + include of headers). So no issue with user having it or needing to link with PKG_LIBS. I have checked the compilation with this Makevars: CXX_STD = CXX11 ROOT_INCLUDE = ../inst/include/ PKG_CPPFLAGS = -I$(ROOT_INCLUDE) PKG_LIBS = -L$(ROOT_INCLUDE) And I still get the same error. Is there anything else to check? The error seems related to a shared object, do I have something special to do? I am not even sure to understand the error message, why it can't load the object if it has compiled? Kind regards, Micha?l
On Wed, Aug 2, 2017 at 8:32 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
On 2 August 2017 at 20:22, Micha?l BENESTY wrote: | Hi, | | I am trying to wrap the Fasttext lib from Facebook on R. | I have wrote a minimal code based on Rcpp.package.skeleton(module = TRUE) | | The C++ file compiles/works with sourceCpp() but it crashes when | building a package. | I have checked many D. Eddelbuettel to get a clue of what to do but no luck. | I have already setup a Makevars file with a path to the include folder. | | The package source code is available there: | https://github.com/pommedeterresautee/FastRText | | My Makevars: | CXX_STD = CXX11 | ROOT_INCLUDE = ../inst/include/ | PKG_CPPFLAGS=-I$(ROOT_INCLUDE) If this is a library then you need to __link__ to it as well. That is commonly done via PKG_LIBS=... and it may get you the additional problem of having to ensure users of your package have the fastText library installed. Dirk | | | The error I am seeing: | ==> R CMD INSTALL --preclean --no-multiarch --with-keep.source FastRText | ... | Error: package or namespace load failed for ?FastRText? in | dyn.load(file, DLLpath = DLLpath, ...): | impossible de charger l'objet partag? | '/home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so': | /home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so: | undefined symbol: _ZN8fasttext8FastTextC1Ev | | | The full log is available there: | https://github.com/pommedeterresautee/FastRText/issues/1 | | According to c++filt | undefined symbol: _ZN8fasttext8FastTextC1Ev means -> | fasttext::FastText::FastText() | | | Has anyone an idea? | | Kind regards, | Micha?l | ________________ | Micha?l BENESTY | michael at benesty.fr | Please do not print this e-mail unless you really need to. | _______________________________________________ | Rcpp-devel mailing list | Rcpp-devel at lists.r-forge.r-project.org | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel -- http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
On 2 August 2017 at 21:02, Micha?l BENESTY wrote:
| Thank you Dirk for this answer. | | The source code of Fasttext is already embedded in the package (it is | the content of ../inst/include/ and is linked with PKG_CPPFLAGS + | include of headers). | So no issue with user having it or needing to link with PKG_LIBS. | | I have checked the compilation with this Makevars: | CXX_STD = CXX11 | ROOT_INCLUDE = ../inst/include/ | PKG_CPPFLAGS = -I$(ROOT_INCLUDE) | PKG_LIBS = -L$(ROOT_INCLUDE) | | And I still get the same error. | | | Is there anything else to check? | The error seems related to a shared object, do I have something special to do? | I am not even sure to understand the error message, why it can't load | the object if it has compiled? Pardon for me being blunt, but you still appear to be confused. Simply copying headers _and source files_ into inst/include/ does not magically create a library. You are, from the looks of it, simply not fully aware of what exactly building a package _against an external library_ needs. So you need to learn this. Resist the urge to immediately reply to this email, but rather try to read up and study some more package. Most of mine use _external_ libraries (not embedded and built on default) but eg the older RcppMLPACK (by KK) is a working example (cf https://github.com/rcppmlpack/RcppMLPACK1) as are several of Jeroen's packages (eg https://github.com/ropensci/hunspell/ as one semi-random pick). Dirk | Kind regards, | Micha?l | |
| On Wed, Aug 2, 2017 at 8:32 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
| >
| > On 2 August 2017 at 20:22, Micha?l BENESTY wrote:
| > | Hi, | > | | > | I am trying to wrap the Fasttext lib from Facebook on R. | > | I have wrote a minimal code based on Rcpp.package.skeleton(module = TRUE) | > | | > | The C++ file compiles/works with sourceCpp() but it crashes when | > | building a package. | > | I have checked many D. Eddelbuettel to get a clue of what to do but no luck. | > | I have already setup a Makevars file with a path to the include folder. | > | | > | The package source code is available there: | > | https://github.com/pommedeterresautee/FastRText | > | | > | My Makevars: | > | CXX_STD = CXX11 | > | ROOT_INCLUDE = ../inst/include/ | > | PKG_CPPFLAGS=-I$(ROOT_INCLUDE) | > | > If this is a library then you need to __link__ to it as well. That is | > commonly done via PKG_LIBS=... and it may get you the additional problem of | > having to ensure users of your package have the fastText library installed. | > | > Dirk | > | | > | | > | The error I am seeing: | > | ==> R CMD INSTALL --preclean --no-multiarch --with-keep.source FastRText | > | ... | > | Error: package or namespace load failed for ?FastRText? in | > | dyn.load(file, DLLpath = DLLpath, ...): | > | impossible de charger l'objet partag? | > | '/home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so': | > | /home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so: | > | undefined symbol: _ZN8fasttext8FastTextC1Ev | > | | > | | > | The full log is available there: | > | https://github.com/pommedeterresautee/FastRText/issues/1 | > | | > | According to c++filt | > | undefined symbol: _ZN8fasttext8FastTextC1Ev means -> | > | fasttext::FastText::FastText() | > | | > | | > | Has anyone an idea? | > | | > | Kind regards, | > | Micha?l | > | ________________ | > | Micha?l BENESTY | > | michael at benesty.fr | > | Please do not print this e-mail unless you really need to. | > | _______________________________________________ | > | Rcpp-devel mailing list | > | Rcpp-devel at lists.r-forge.r-project.org | > | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel | > -- | > http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
Hi, Michael, All the ".cc" files need to be compiled to make your package work. Putting them in the inst/include folder is not enough. I made some quick changes in your package and please check the attachment. Best, Qiang Kou
On Wed, Aug 2, 2017 at 11:22 AM, Micha?l BENESTY <michael at benesty.fr> wrote:
Hi, I am trying to wrap the Fasttext lib from Facebook on R. I have wrote a minimal code based on Rcpp.package.skeleton(module = TRUE) The C++ file compiles/works with sourceCpp() but it crashes when building a package. I have checked many D. Eddelbuettel to get a clue of what to do but no luck. I have already setup a Makevars file with a path to the include folder. The package source code is available there: https://github.com/pommedeterresautee/FastRText My Makevars: CXX_STD = CXX11 ROOT_INCLUDE = ../inst/include/ PKG_CPPFLAGS=-I$(ROOT_INCLUDE) The error I am seeing: ==> R CMD INSTALL --preclean --no-multiarch --with-keep.source FastRText ... Error: package or namespace load failed for ?FastRText? in dyn.load(file, DLLpath = DLLpath, ...): impossible de charger l'objet partag? '/home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/ FastRText/libs/FastRText.so': /home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/ FastRText/libs/FastRText.so: undefined symbol: _ZN8fasttext8FastTextC1Ev The full log is available there: https://github.com/pommedeterresautee/FastRText/issues/1 According to c++filt undefined symbol: _ZN8fasttext8FastTextC1Ev means -> fasttext::FastText::FastText() Has anyone an idea? Kind regards, Micha?l
________________ Micha?l BENESTY michael at benesty.fr Please do not print this e-mail unless you really need to. _______________________________________________ Rcpp-devel mailing list Rcpp-devel at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Qiang Kou qkou at umail.iu.edu School of Informatics and Computing, Indiana University -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170802/086790bf/attachment-0001.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: FastRText_1.0.tar.gz Type: application/x-gzip Size: 23356 bytes Desc: not available URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170802/086790bf/attachment-0001.bin>
Thank you a lot Mr. Kou. The package is now compiling and I have updated it to load modules at loading of the package (was quite tricky). Just to understand, the .cc has compiled just because you moved them in src/ folder, am I right? The -I flag in Makevars was not enough? Kind regards, Micha?l ________________ Micha?l BENESTY michael at benesty.fr Please do not print this e-mail unless you really need to.
On Wed, Aug 2, 2017 at 10:42 PM, Qiang Kou <qkou at umail.iu.edu> wrote:
Hi, Michael, All the ".cc" files need to be compiled to make your package work. Putting them in the inst/include folder is not enough. I made some quick changes in your package and please check the attachment. Best, Qiang Kou On Wed, Aug 2, 2017 at 11:22 AM, Micha?l BENESTY <michael at benesty.fr> wrote:
Hi, I am trying to wrap the Fasttext lib from Facebook on R. I have wrote a minimal code based on Rcpp.package.skeleton(module = TRUE) The C++ file compiles/works with sourceCpp() but it crashes when building a package. I have checked many D. Eddelbuettel to get a clue of what to do but no luck. I have already setup a Makevars file with a path to the include folder. The package source code is available there: https://github.com/pommedeterresautee/FastRText My Makevars: CXX_STD = CXX11 ROOT_INCLUDE = ../inst/include/ PKG_CPPFLAGS=-I$(ROOT_INCLUDE) The error I am seeing: ==> R CMD INSTALL --preclean --no-multiarch --with-keep.source FastRText ... Error: package or namespace load failed for ?FastRText? in dyn.load(file, DLLpath = DLLpath, ...): impossible de charger l'objet partag? '/home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so': /home/geantvert/R/x86_64-pc-linux-gnu-library/3.4/FastRText/libs/FastRText.so: undefined symbol: _ZN8fasttext8FastTextC1Ev The full log is available there: https://github.com/pommedeterresautee/FastRText/issues/1 According to c++filt undefined symbol: _ZN8fasttext8FastTextC1Ev means -> fasttext::FastText::FastText() Has anyone an idea? Kind regards, Micha?l
________________ Micha?l BENESTY michael at benesty.fr Please do not print this e-mail unless you really need to. _______________________________________________ Rcpp-devel mailing list Rcpp-devel at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-- Qiang Kou qkou at umail.iu.edu School of Informatics and Computing, Indiana University
Micha?l Benesty has written at Wed, 2 Aug 2017 23:26:26 +0200
Thank you a lot Mr. Kou. The package is now compiling and I have updated it to load modules at loading of the package (was quite tricky). Just to understand, the .cc has compiled just because you moved them in src/ folder, am I right?
Besides compilation issue, it is generally a bad idea to put sources in inst/ tree. Because everything in inst/ is installed when binary installation is requested. So someone wishing only binaries (let say for the sake of disk space) will drag also the sources. A notorious exception to this rule are header only packages, like BH. But as far as I understand it is not your case, right? Serguei. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170802/6d41cd68/attachment.html>