r-spatial / sf

Simple Features for R
https://r-spatial.github.io/sf/
Other
1.33k stars 293 forks source link

Unable to compile from source for R 4.3.0 on Windows 10 #2162

Closed mfherman closed 1 year ago

mfherman commented 1 year ago

Describe the bug I am unable to install sf from source (via CRAN or GitHub). I have Rtools 43 installed and am able to successfully compile other R packages from source.

I am not expert at reading the compilation details, but it seems like it is getting hung up when using libwebp-1.3.0. Here are the lines directly before the comipilation error:

C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:/rtools43/x86_64-w64-mingw32.static.posix/lib/libwebp.a(libwebpencode_la-picture_csp_enc.o): in function `ImportYUVAFromRGBA':
/root/mxe/tmp-libwebp-x86_64-w64-mingw32.static.posix/libwebp-1.3.0/src/enc/picture_csp_enc.c:508: undefined reference to `SharpYuvInit'
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:/rtools43/x86_64-w64-mingw32.static.posix/lib/libwebp.a(libwebpencode_la-picture_csp_enc.o): in function `PreprocessARGB':
/root/mxe/tmp-libwebp-x86_64-w64-mingw32.static.posix/libwebp-1.3.0/src/enc/picture_csp_enc.c:180: undefined reference to `SharpYuvGetConversionMatrix'
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: /root/mxe/tmp-libwebp-x86_64-w64-mingw32.static.posix/libwebp-1.3.0/src/enc/picture_csp_enc.c:180: undefined reference to `SharpYuvConvert'
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'sf'
* removing 'C:/Users/mherman/AppData/Local/R/win-library/4.3/sf'
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status
Full output from my R session ```` > install.packages("sf") Installing package into ‘C:/Users/mherman/AppData/Local/R/win-library/4.3’ (as ‘lib’ is unspecified) Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘sf’ installing the source package ‘sf’ trying URL 'https://packagemanager.rstudio.com/all/latest/src/contrib/sf_1.0-12.tar.gz' Content type 'binary/octet-stream' length 3542422 bytes (3.4 MB) downloaded 3.4 MB * installing *source* package 'sf' ... ** package 'sf' successfully unpacked and MD5 sums checked ** using staged installation ********************************************** WARNING: this package has a configure script It probably needs manual configuration ********************************************** ** libs using C++ compiler: 'G__~1.EXE (GCC) 12.2.0' rm -f sf.dll RcppExports.o bbox.o gdal.o gdal_geom.o gdal_read.o gdal_utils.o gdal_write.o geos.o hex.o mdim.o ops.o polygonize.o proj.o proj_info.o raster2sf.o sfc-sfg.o signed_area.o stars.o wkb.o zm_range.o cp -r "C:/rtools43/x86_64-w64-mingw32.static.posix/share/gdal" ../inst/ cp -r "C:/rtools43/x86_64-w64-mingw32.static.posix/share/proj" ../inst/ g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c bbox.cpp -o bbox.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c gdal.cpp -o gdal.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c gdal_geom.cpp -o gdal_geom.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c gdal_read.cpp -o gdal_read.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c gdal_utils.cpp -o gdal_utils.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c gdal_write.cpp -o gdal_write.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c geos.cpp -o geos.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c hex.cpp -o hex.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c mdim.cpp -o mdim.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c ops.cpp -o ops.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c polygonize.cpp -o polygonize.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c proj.cpp -o proj.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c proj_info.cpp -o proj_info.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c raster2sf.cpp -o raster2sf.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c sfc-sfg.cpp -o sfc-sfg.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c signed_area.cpp -o signed_area.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c stars.cpp -o stars.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c wkb.cpp -o wkb.o g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -DHAVE_PROJ_H -I'C:/Users/mherman/AppData/Local/R/win-library/4.3/Rcpp/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c zm_range.cpp -o zm_range.o g++ -std=gnu++17 -shared -s -static-libgcc -o sf.dll tmp.def RcppExports.o bbox.o gdal.o gdal_geom.o gdal_read.o gdal_utils.o gdal_write.o geos.o hex.o mdim.o ops.o polygonize.o proj.o proj_info.o raster2sf.o sfc-sfg.o signed_area.o stars.o wkb.o zm_range.o -fopenmp -lgdal -larmadillo -lopenblas -lgfortran -lquadmath -lpq -lpgcommon -lpgport -lodbc32 -lodbccp32 -lblosc -lkea -lhdf5_cpp -lhdf5 -lpoppler -llcms2 -lfreetype -lharfbuzz -lfreetype -llz4 -lpcre2-8 -lxml2 -lopenjp2 -lnetcdf -lmysqlclient -lspatialite -lgeos_c -lgeos -lminizip -lgeos -ljson-c -lgta -lfreexl -lexpat -lssl -lpsapi -lgif -lmfhdf -lhdf5_hl -lcrypto -lportablexdr -ldf -lhdf5 -lsz -lpng16 -lpng -lpoppler -llcms2 -lfreetype -lharfbuzz -lfreetype -llz4 -lpcre2-8 -lpcre -lcurl -lbcrypt -lrtmp -lssl -lssh2 -lidn2 -lunistring -liconv -lgcrypt -lcrypto -lgpg-error -lws2_32 -ltiff -llzma -ljpeg -lz -lcfitsio -lzstd -lwebpdecoder -lwebp -lsbml-static -lgeotiff -lproj -lsqlite3 -lbz2 -lcrypt32 -lwldap32 -lsecur32 -LC:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools43/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-43~1.0/bin/x64 -lR C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:/rtools43/x86_64-w64-mingw32.static.posix/lib/libwebp.a(libwebpencode_la-picture_csp_enc.o): in function `ImportYUVAFromRGBA': /root/mxe/tmp-libwebp-x86_64-w64-mingw32.static.posix/libwebp-1.3.0/src/enc/picture_csp_enc.c:508: undefined reference to `SharpYuvInit' C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: C:/rtools43/x86_64-w64-mingw32.static.posix/lib/libwebp.a(libwebpencode_la-picture_csp_enc.o): in function `PreprocessARGB': /root/mxe/tmp-libwebp-x86_64-w64-mingw32.static.posix/libwebp-1.3.0/src/enc/picture_csp_enc.c:180: undefined reference to `SharpYuvGetConversionMatrix' C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: /root/mxe/tmp-libwebp-x86_64-w64-mingw32.static.posix/libwebp-1.3.0/src/enc/picture_csp_enc.c:180: undefined reference to `SharpYuvConvert' collect2.exe: error: ld returned 1 exit status no DLL was created ERROR: compilation failed for package 'sf' * removing 'C:/Users/mherman/AppData/Local/R/win-library/4.3/sf' Warning in install.packages : installation of package ‘sf’ had non-zero exit status ````
Session info ```` R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045) Matrix products: default locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C [5] LC_TIME=English_United States.utf8 time zone: America/New_York tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 rstudioapi_0.14 ````
edzer commented 1 year ago

That looks identical to what we now see on CRAN r-release-windows: https://www.r-project.org/nosvn/R.check/r-release-windows-x86_64/sf-00install.html . @kalibera any idea?

rsbivand commented 1 year ago

Travelling until Monday. Will look then.

kalibera commented 1 year ago

One needs also to link sharpy separately, I am using this patch: https://svn.r-project.org/R-dev-web/trunk/WindowsBuilds/winutf8/ucrt3/r_packages/patches/CRAN/sf.diff

edzer commented 1 year ago

Great thanks - committed in https://github.com/r-spatial/sf/commit/9a30544b35c4b73297e65828741efc4fbbe02dd5 ; @mfherman maybe you could try compiling from the main branch?

kadyb commented 1 year ago

It seems that the same errors on CI on Windows (https://github.com/r-spatial/sf/actions/runs/4943832015/jobs/8838711881) are now fixed.

rsbivand commented 1 year ago

I did update rgdal with the patches, so there is something to compare with.

mfherman commented 1 year ago

Just compiled successfully from main. Thanks so much for the quick fix!