Sue McDonald
2015-May-29 20:16 UTC
[Rd] Compiling 64bit static library for Windows (Rtools33, MSYS2, cross-compile on linux)
My apologies for cross-posting. I found this site, after I had posted on stack-overflow. I need to compile several static libraries (C & Fortran) which will later be linked with an R package. Rtools33 directory includes /i686-w64-mingw32 directory which I understand creates 32 bit binaries. Yet, there are other 64 bit directories as well. I have three related questions: 1. Can Rtools33 be used to compile static libraries as a separate step using -m64 flag? 2. MSYS2 is very convenient for compiling many of these libraries. Can a static library compiled with x86_64-w64-mingw32 (gcc 4.9.2) be used with Rtools33 (v 4.6.2)? 3. Can a static library compiled using x86_64-w64-mingw32-gcc cross-compiler (v 4.6.2) on linux be used with Rtools33? Options 2 and 3 are preferable for convenience and speed. Compiling all libraries as part of the R-package is not currently an option. Thanks, SM [[alternative HTML version deleted]]
Duncan Murdoch
2015-May-30 12:14 UTC
[Rd] Compiling 64bit static library for Windows (Rtools33, MSYS2, cross-compile on linux)
On 29/05/2015 4:16 PM, Sue McDonald wrote:> My apologies for cross-posting. I found this site, after I had posted on > stack-overflow. > > I need to compile several static libraries (C & Fortran) which will later > be linked with an R package. Rtools33 directory includes /i686-w64-mingw32 > directory which I understand creates 32 bit binaries. Yet, there are other > 64 bit directories as well.The current Rtools is set up for multilib operation. You only need to use the binaries in Rtools/gcc-4.6.3/bin. The executables there will choose files from the other directories depending on the -m32 or -m64 flag, for 32 bit or 64 bit operation.> > I have three related questions: > > 1. > > Can Rtools33 be used to compile static libraries as a separate step > using -m64 flag?Yes, I believe so. They would be 64 bit static libraries.> 2. > > MSYS2 is very convenient for compiling many of these libraries. Can a > static library compiled with x86_64-w64-mingw32 (gcc 4.9.2) be used with > Rtools33 (v 4.6.2)?Rtools uses 4.6.3, not 4.6.2. I would assume the runtime libraries are different between 4.6.3 and 4.9.2, so you won't be able to mix versions like that. However, you should be able to use your MSYS2 system for all compilation, if you create a MkRules.local file with the right settings. You will need to compile R and all packages and libraries using that system, don't expect to be able to mix binaries from different versions of gcc.> 3. > > Can a static library compiled using x86_64-w64-mingw32-gcc > cross-compiler (v 4.6.2) on linux be used with Rtools33?Some libraries used by packages are compiled by Brian Ripley using a cross-compiler on linux. I'd assume he's using 4.6.3 as with the Rtools build, but I'm not sure about that. Duncan Murdoch> > Options 2 and 3 are preferable for convenience and speed. > > Compiling all libraries as part of the R-package is not currently an option. > > Thanks, > > SM > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >
Jeroen Ooms
2015-May-30 14:07 UTC
[Rd] Compiling 64bit static library for Windows (Rtools33, MSYS2, cross-compile on linux)
Hi Sue, I maintain a few static libs for R packages on https://github.com/rwinlib. If your R packages are open source I can try to add the libraries you need. Answers inline:> Can Rtools33 be used to compile static libraries as a separate step > using -m64 flag?Yes, but usually you'll need msys to as well to run configure, etc.> MSYS2 is very convenient for compiling many of these libraries. Can a > static library compiled with x86_64-w64-mingw32 (gcc 4.9.2) be used with > Rtools33 (v 4.6.2)?Sometimes. It will not work for c++ libraries because the gcc build included with msys2 uses a different exception and threading models. For C libraries, sometimes building in msys2 leads the static library to depend on certain system libraries that are included with msys2 but not with rtools.> Can a static library compiled using x86_64-w64-mingw32-gcc > cross-compiler (v 4.6.2) on linux be used with Rtools33?If the library is built properly, this is usually not a problem; most builds do not depend on a particular gcc version. For example static and dynamic libraries for libcurl and dependencies (openssl, libssh2, libz, etc) are available via http://curl.haxx.se/gknw.net/7.40.0/ and in my experience these can be linked with any somewhat recent version of gcc.
Prof Brian Ripley
2015-May-30 19:06 UTC
[Rd] Compiling 64bit static library for Windows (Rtools33, MSYS2, cross-compile on linux)
On 30/05/2015 13:14, Duncan Murdoch wrote:> On 29/05/2015 4:16 PM, Sue McDonald wrote: >> My apologies for cross-posting. I found this site, after I had posted on >> stack-overflow. >> >> I need to compile several static libraries (C & Fortran) which will later >> be linked with an R package. Rtools33 directory includes /i686-w64-mingw32 >> directory which I understand creates 32 bit binaries. Yet, there are other >> 64 bit directories as well. > > The current Rtools is set up for multilib operation. You only need to > use the binaries in Rtools/gcc-4.6.3/bin. The executables there will > choose files from the other directories depending on the -m32 or -m64 > flag, for 32 bit or 64 bit operation. > >> >> I have three related questions: >> >> 1. >> >> Can Rtools33 be used to compile static libraries as a separate step >> using -m64 flag? > > Yes, I believe so. They would be 64 bit static libraries. > >> 2. >> >> MSYS2 is very convenient for compiling many of these libraries. Can a >> static library compiled with x86_64-w64-mingw32 (gcc 4.9.2) be used with >> Rtools33 (v 4.6.2)? > > Rtools uses 4.6.3, not 4.6.2. I would assume the runtime libraries are > different between 4.6.3 and 4.9.2, so you won't be able to mix versions > like that. > > However, you should be able to use your MSYS2 system for all > compilation, if you create a MkRules.local file with the right settings. > You will need to compile R and all packages and libraries using that > system, don't expect to be able to mix binaries from different versions > of gcc. > > >> 3. >> >> Can a static library compiled using x86_64-w64-mingw32-gcc >> cross-compiler (v 4.6.2) on linux be used with Rtools33? > > Some libraries used by packages are compiled by Brian Ripley using a > cross-compiler on linux. I'd assume he's using 4.6.3 as with the Rtools > build, but I'm not sure about that.Correct, I used the cross-compiler that was used to compile the native compilers in Rtools. My experience (this had to work for thousands of packages for CRAN) is that only an exact match for the cross-compiler to the compiler used to compile R works reliably. Even very slightly different builds can cause segfaults. -- Brian D. Ripley, ripley at stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford 1 South Parks Road, Oxford OX1 3TG, UK
Apparently Analagous Threads
- Compiling 64bit static library for Windows (Rtools33, MSYS2, cross-compile on linux)
- Compiling 64bit static library for Windows (Rtools33, MSYS2, cross-compile on linux)
- New version of Rtools for Windows
- New version of Rtools for Windows
- New version of Rtools for Windows