Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of gzip #49

Closed
sanglier91 opened this issue Sep 14, 2017 · 3 comments
Closed

Use of gzip #49

sanglier91 opened this issue Sep 14, 2017 · 3 comments

Comments

@sanglier91
Copy link

Hi,

First of all thank you for this very useful package.
I would like to use it inside a package to read a gzip file.
At the end of the compilation, I get the following error message:

** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/xxxxxxxxxxxxx/NeutronMultiplicityCounting.so':
  /xxxxxxxxxxxxxxxxxxxxx/NeutronMultiplicityCounting/libs/NeutronMultiplicityCounting.so: undefined symbol: _ZN5boost9iostreams4zlib8deflatedE
Error: loading failed
Execution halted
ERROR: loading failed

I believe the error come from the header file <boost/iostreams/filter/gzip.hpp> that I need. It uses the zlib.hpp file that declare the following variable:

BOOST_IOSTREAMS_DECL extern const int deflated;

My DESCRIPTION file declare BH under the LinkingTo section.

I use other functions from BH without any problem.

I can solve the problem by adding the following line to my Makevars file but I guess this is not the right way to do:

PKG_LIBS = -L/usr/lib/x86_64-linux-gnu/ -lboost_iostreams -lboost_filesystem

Wilfried

@eddelbuettel
Copy link
Owner

eddelbuettel commented Sep 14, 2017

I can take a look but note first that you do not need Boost to open gzip'ed file. R already does it via all of read.table() and variants, and you can also do it in plain C/C++ code via gzopen() -- which should also "just work" because R is always built wiith that library.

As for "I can solve it this" that is indeed correct, but your package now becomes less portable as all users would have to have these libraries available "and visible". Unlikely on Windows. In short, this is the difference between using Boost as header-only (as BH) or using Boost full-fledged with linking. Some libraries and components only work in the latter way. It is up to you balance those costs and benefits.

@sanglier91
Copy link
Author

I didn't know about gzopen(). I'm going to change my code in order to use it. Thank you. Please let me know if you find the reason of the error.

@eddelbuettel
Copy link
Owner

Yes, gzopen() is gold. Been using it for decades (!!).

I told you the error. The way Boost implements this requires linking with Boost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants