I am compiling an R package containing .cpp
source files from a third party. To compile the .cpp
files into a static library, I am using the Makevars.win
file (link). I stumbled upon an odd behavior of SHLIB
on Windows only, while trying to fix another problem related to parallel make
which revealed that I had a misplaced parenthesis defining $(SHLIB)
as ($SHLIB)
in Makevars
and Makevars.win
files (link).
Long story short, I had written $(SHLIB)
incorrectly as ($SHILB)
in my Makevars
and Makevars.win
files. Correcting that mistake gives me no error on Linux
and OSX
machines, but on Windows ($SHLIB)
works, but $(SHLIB)
gives me the following error:
C:\Rtools\mingw_64\bin\nm.exe: cvode_bandpre_impl.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_bbdpre_impl.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_diag_impl.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_direct_impl.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_impl.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_spils_impl.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_bandpre.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_bbdpre.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_diag.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_direct.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_impl.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: cvode_spils.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: fnvector_serial.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: nvector_serial.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_band.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_config.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_dense.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_direct.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_fconfig.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_fnvector.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_iterative.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_linearsolver.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_math.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_matrix.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_nvector.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_pcg.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_sparse.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_spbcgs.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_spfgmr.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_spgmr.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_sptfqmr.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_types.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sundials_version.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: fsunlinsol_dense.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunlinsol_band.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunlinsol_dense.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunlinsol_pcg.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunlinsol_spbcgs.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunlinsol_spfgmr.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunlinsol_spgmr.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunlinsol_sptfqmr.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: fsunmatrix_dense.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: fsunmatrix_band.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunmatrix_band.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunmatrix_dense.h: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: sunmatrix_sparse.h: File format not recognized
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o sundialr.dll tmp.def cvode.o RcppExports.o -LC:/PROGRA~1/R/R-34~1.1/bin/x64 -lRlapack -LC:/PROGRA~1/R/R-34~1.1/bin/x64 -lRblas -lgfortran -lm -lquadmath -L../inst/ -lsundials_all -Ld:/Compiler/gcc-4.9.3/local330/lib/x64 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.1/bin/x64 -lR
../inst//libsundials_all.a(cvode_bandpre.o):cvode_bandpre.c:(.text+0x679): undefined reference to `SUNBandLinearSolver'
../inst//libsundials_all.a(cvode_bandpre.o):cvode_bandpre.c:(.text+0x360): undefined reference to `SUNLinSolSetup_Band'
../inst//libsundials_all.a(cvode_bbdpre.o):cvode_bbdpre.c:(.text+0x819): undefined reference to `SUNBandLinearSolver'
../inst//libsundials_all.a(cvode_bbdpre.o):cvode_bbdpre.c:(.text+0x2ea): undefined reference to `SUNLinSolSetup_Band'
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'sundialr'
I understand the undefined reference
error messages are linking errors, but I am not sure why I am getting the File format not recognized
error messages for header files. More interestingly, why it all works fine with substituting $(SHLIB)
with ($SHLIB)
in the Makevars.win
file when the WRE document talks about $(SHLIB)
and not ($SHLIB)
. In fact, the package passed all CRAN checks and was on CRAN till very recently with ($SHLIB)
in Makevars.win
.
Can any one explain why this is happening and how can I resolve the errors I am getting with $(SHLIB)
now. I would like to replace the erroneous ($SHLIB)
in my code. Thanks!