Skip to content

[Bioc-devel] Rhtslib-linked package not compiling on Windows

3 messages · Hervé Pagès, Lucas Nell

#
Hello,

I'm having trouble linking to Rhtslib on Windows, specifically with finding
some of the required linked libraries (libcurl, among others). I made a
simple R package with only one function that compresses a file using BGZF
(link here <https://github.com/lucasnell/RhtslibTest>). After reading
through the Rhtslib instructions again, I tried building the package on
Windows 10 and got the output below. The directory C:/extsoft does not
exist, so I feel like there's something else I need to install.

Thanks for your help! (And thank you to the Rhtslib creators for a super
useful package!)

Cheers,
Lucas


==> Rcpp::compileAttributes()

* Updated R/RcppExports.R

==> Rcmd.exe INSTALL --preclean --no-multiarch --with-keep.source
RhtslibTest

* installing to library 'C:/Users/acuit/Documents/R/win-library/3.6'
* installing *source* package 'RhtslibTest' ...
** using staged installation
** libs
C:/Rtools/mingw_64/bin/g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-36~1.2/include"
-DNDEBUG -D_FILE_OFFSET_BITS=64
-I"C:/Users/acuit/Documents/R/win-library/3.6/Rcpp/include"
-I"C:/Users/acuit/Documents/R/win-library/3.6/Rhtslib/include"
-I"C:/Users/acuit/Documents/R/win-library/3.6/zlibbioc/include"        -O2
-Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
C:/Rtools/mingw_64/bin/g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-36~1.2/include"
-DNDEBUG -D_FILE_OFFSET_BITS=64
-I"C:/Users/acuit/Documents/R/win-library/3.6/Rcpp/include"
-I"C:/Users/acuit/Documents/R/win-library/3.6/Rhtslib/include"
-I"C:/Users/acuit/Documents/R/win-library/3.6/zlibbioc/include"        -O2
-Wall  -mtune=generic -c write_bgzf.cpp -o write_bgzf.o
write_bgzf.cpp: In function 'int compress_file(const string&, const int&)':
write_bgzf.cpp:54:9: warning: variable 'in_code' set but not used
[-Wunused-but-set-variable]
     int in_code;
         ^
C:/Rtools/mingw_64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o
RhtslibTest.dll tmp.def RcppExports.o write_bgzf.o
C:/Users/acuit/Documents/R/win-library/3.6/Rhtslib/usrlib/x64/libhts.a
-LC:/extsoft/lib/x64 -lcurl -lrtmp -lssl -lssh2 -lcrypto -lgdi32 -lz
-lws2_32 -lwldap32 -lwinmm -LC:/PROGRA~1/R/R-36~1.2/bin/x64 -lR
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lcurl
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lrtmp
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lssl
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lssh2
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lcrypto
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'RhtslibTest'
* removing 'C:/Users/acuit/Documents/R/win-library/3.6/RhtslibTest'

Exited with status 1.
#
Hi Lucas,

In order to compile an Rhtslib client package on Windows you need a 
setup that mimics closely what we have on our Windows builders. In 
particular you need to install a bunch of external libraries in 
C:\extsoft and edit R\etc\i386\Makeconf and R\etc\x64\Makeconf to let R 
know about these external libraries. The exact setup is documented here:

 
https://github.com/Bioconductor/BBS/blob/master/Doc/Prepare-Windows-Server-2012-HOWTO.md

End users don't need any of this because they typically install the 
Windows package binaries which are statically linked.

Unfortunately, if Windows is the platform where you intend to develop 
your package, you'll have to go thru the complicated setup described 
above. Alternatively, if that's an option for you, you could develop 
your package on Linux. Installing the external libraries there is very 
easy so the development process will be a lot easier. Then, when you 
summit your package to Bioconductor, we'll start building the Windows 
and Mac binaries for you so you'll get build reports for these 
platforms. Also, once the package is accepted, we'll distribute the 
Windows and Mac binaries so on these platforms your users won't need any 
of the external dependencies.

Hope this helps,

H.
On 1/20/20 14:09, Lucas Nell wrote:

  
    
5 days later
#
Hello Herve,

Thank you so much for your help! The package I'm developing is actually on
CRAN, but using the new Rtools40 with gcc 8.0 seems to work. For a testing
environment on Windows, win-builder
<https://win-builder.r-project.org/upload.aspx> has a version that uses
Rtools40.

Cheers,
Lucas
On Tue, Jan 21, 2020 at 12:16 PM Pages, Herve <hpages at fredhutch.org> wrote: