rwinlib / gdal3

GDAL 3 stack for sf and rgdal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conda Forge build failures

mfansler opened this issue · comments

Conda Forge has been unable to build any R packages depending on this. Here is an example failure from the latest attempt at building the terra package:

Example Build Failure

g++ -shared -s -o terra.dll tmp.def RcppExports.o RcppFunctions.o RcppModule.o arith.o concaveman.o crs.o distRaster.o distance.o extract.o file_utils.o focal.o gcp.o gdal_algs.o gdal_multidimensional.o gdalio.o geodesic.o geos_methods.o geosphere.o math_utils.o mediancut.o memory.o movingWindow.o ncdf.o ram.o raster_methods.o raster_stats.o rasterize.o read.o read_gdal.o read_ogr.o sample.o spatBase.o spatDataframe.o spatFactor.o spatRaster.o spatRasterMultiple.o spatSources.o spatTime.o spatVector.o spatVector2.o string_utils.o vecmath.o vecmathse.o vector_methods.o write.o write_gdal.o write_ogr.o -L../windows/gdal3-3.4.1/lib-5.3.0/x64 -L../windows/gdal3-3.4.1/lib/x64 -lgdal -lsqlite3 -lspatialite -lproj -lgeos_c -lgeos -ljson-c -lnetcdf -lmariadbclient -lpq -lpgport -lpgcommon -lwebp -lcurl -lssh2 -lssl -lhdf5_hl -lhdf5 -lexpat -lfreexl -lcfitsio -lmfhdf -lhdf -lxdr -lpcre -lopenjp2 -ljasper -lpng -ljpeg -ltiff -lgeotiff -lgif -lxml2 -llzma -lz -lzstd -lodbc32 -lodbccp32 -liconv -lpsapi -lwldap32 -lsecur32 -lgdi32 -lnormaliz -lcrypto -lcrypt32 -lws2_32 -lshlwapi -lbcrypt -LD:/bld/r-terra_1674580232111/_h_env/lib/R/bin/x64 -lR
../windows/gdal3-3.4.1/lib/x64/libgdal.a(ogrfeature.o):(.text+0x4e67): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libgdal.a(ogrgeometry.o):(.text+0x1e0f): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libgdal.a(gdalinfo_lib.o):(.text+0x32): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libgdal.a(gt_jpeg_copy.o):(.text+0x263): undefined reference to `__intrinsic_setjmpex'
../windows/gdal3-3.4.1/lib/x64/libgdal.a(inventory.o):(.text+0x4a4): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libgdal.a(jpgdataset.o):(.text+0x648): undefined reference to `__intrinsic_setjmpex'
../windows/gdal3-3.4.1/lib/x64/libgdal.a(jpgdataset.o):(.text+0x6c0): undefined reference to `__imp___acrt_iob_func'
# [abridged] ...
../windows/gdal3-3.4.1/lib/x64/libpng.a(png.o):(.text+0x1c19): undefined reference to `__intrinsic_setjmpex'
../windows/gdal3-3.4.1/lib/x64/libpng.a(pngerror.o):(.text+0x370): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libpng.a(pngerror.o):(.text+0x755): undefined reference to `__intrinsic_setjmpex'
../windows/gdal3-3.4.1/lib/x64/libjpeg.a(jerror.c.obj):(.text+0x19d): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libjpeg.a(jmemmgr.c.obj):(.text+0x111a): undefined reference to `__stdio_common_vsscanf'
../windows/gdal3-3.4.1/lib/x64/libgeotiff.a(cpl_serv.o):(.text+0x2cc): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libxml2.a(error.o):(.text+0x227): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libxml2.a(parserInternals.o):(.text+0x5ee): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libxml2.a(tree.o):(.text+0xa62c): undefined reference to `__imp___acrt_iob_func'
../windows/gdal3-3.4.1/lib/x64/libxml2.a(xmlIO.o):(.text+0x4af): more undefined references to `__imp___acrt_iob_func' follow
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'terra'

From searching, this seems like perhaps a UCRT version issue (unsure - I don't use Windows myself). Do you have any insights into what is going on here and how to address it?

R has switched to ucrt compilers last year. R versions 4.2 and up use a new toolchain system based on MXE, called rtools42. This rtools42 bundle includes all the system libraries. The ucrt version of R no longer downloads libraries from rwinlib, but instead uses gdal from rtools42.

Put simply: compiling R packages with conda's msvcrt gcc is no longer supported. The only way to make things work well is switch your build system to a ucrt compiler; preferable the official rtools42 compiler bundle. See also: conda-forge/conda-forge.github.io#1654 (comment)

based on this it seems you can also do

conda install -c conda-forge r-terra

@rhijmans I think he is the maintainer of conda-forge r-terra and is trying to update it.

Oh that is funny. Sorry for the static!

Thanks for sharing your insight and for the references! A point to clarify though is that the logged failures are for R 4.1 builds, which are still using the Makevars.win and consequently these static libs. I'm unsure how rtools42 applies in that context.