[Bioc-devel] What to do about std::cerr/cout warnings in external libraries?

Shian Su su.s at wehi.edu.au
Wed Jun 21 04:57:51 CEST 2017

Thanks Martin,

Should this be as simple as removing all my local htslib files, adding the LinkingTo specifiers and rebuilding? Currently getting

Error in dyn.load(dllfile) :
  unable to load shared object ‘~/Programs/R/scPipe/src/scPipe.so':
  dlopen(~/Programs/R/scPipe/src/scPipe.so, 6): Symbol not found: _seq_nt16_table
  Referenced from: ~/Programs/R/scPipe/src/scPipe.so
  Expected in: flat namespace
 in ~/Programs/R/scPipe/src/scPipe.so

Perhaps I’ve done something silly.


On 21 Jun 2017, at 12:12 pm, Martin Morgan <martin.morgan at roswellpark.org<mailto:martin.morgan at roswellpark.org>> wrote:

On 06/20/2017 09:38 PM, Shian Su wrote:
My warning is
checking compiled code ... WARNING
File ‘scPipe/libs/scPipe.so’:
  Found ‘___stderrp’, possibly from ‘stderr’ (C)
    Objects: ‘bgzf.o’, ‘hts.o’, ‘sam.o’
  Found ‘_abort’, possibly from ‘abort’ (C)
    Object: ‘sam.o’
  Found ‘_exit’, possibly from ‘exit’ (C)
    Object: ‘bgzf.o’
Compiled code should not call entry points which might terminate R nor
write to stdout/stderr instead of to the console, nor the system RNG.
As far as I can tell my source files are identical to the ones in Rhtslib, how does Rhtslib avoid this warning? I feel safer with one less dependency but I’ll consider linking to Rhtslib, thanks!

please reuse Rhtslib instead of adding code that requires independent maintenance; in particular considerable effort is required to make htslib available across platforms. If there are issues with Rhtslib then report them and, especially if a patch is provided, they will be fixed.

Rhtslib builds the library in src/htslib/.libs/libhts.so whereas R checks src/Rhstlib.so, which contains a single function that reports the version. So R doesn't find the use of stderr, etc.

A previous discussion of similar issues is at


and other posts in the same thread.

For Rsamtools I had introduced in src/Makevars.common a macro that redirects fprintf / exit / abort to code that does not use these macros, but to do so requires unsetting _FORTIFY_SOURCE

 -Dfprintf=_samtools_fprintf \
 -Dexit=_samtools_exit \

but this is not a perfect solution.


On 20 Jun 2017, at 8:03 pm, Vincent Carey <stvjc at channing.harvard.edu<mailto:stvjc at channing.harvard.edu><mailto:stvjc at channing.harvard.edu>> wrote:
Have you looked at the Bioconductor package Rhtslib?
Is your package's source visible on github?  If so please provide the URL.
If not, please provide more details on the error messages observed.
It would seem to me that the best way to proceed would be to link to Rhtslib.
On Tue, Jun 20, 2017 at 2:29 AM, Shian Su <su.s at wehi.edu.au<mailto:su.s at wehi.edu.au><mailto:su.s at wehi.edu.au>> wrote:
Hi all,
I am using parts of htslib in a new package. R CMD check gives me warnings about R terminating entry points and such resulting from htslib’s calls. Is there a way to get around this or do I have to go into the source code of htslib and change all their calls.
Also, Hadley’s best practices recommends using “error” instead of “exit” however I am using Rcpp to glue things together which only seems to provide “stop” for this purpose. Can exits be simply swapped out with Rcpp::stop?
Kind regards,
Shian Su
Bioc-devel at r-project.org<mailto:Bioc-devel at r-project.org><mailto:Bioc-devel at r-project.org> mailing list
[[alternative HTML version deleted]]
Bioc-devel at r-project.org mailing list

This email message may contain legally privileged and/or confidential information.  If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited.  If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you.

	[[alternative HTML version deleted]]

More information about the Bioc-devel mailing list