Dr. Avit Bhowmik | Environmental Scientist · Climate Solutionist

Further problems with dynamic links for R-Grass GIS 7 users in Mac OSX

Image: OS Geo       

I published a post the day before yesterday on workarounds for R-Grass GIS 7 (co-interface) users in Mac OSX, particularly for the ones updated to El Capitan. The major issues for GRASS users in EL Capitan are related to the dynamic links (dyld), for which I offered the solution of including the possible python library paths in the system environment as DYLD_LIBRARY_PATH. Although this solved the problem of initiating GRASS from R interface, the issue of dyld paths persists while calling the 'v.extract' module. Initially, the error appeared to be like the following:

sh: line 1:   485 Trace/BPT trap: 5       'v.extract' --interface-description > '/var/folders/lc/pqsnf65j5td_2vw1wxy016qc0000gn/T//Rtmpx3qe5t/file1c7612c470c' 2> '/var/folders/lc/pqsnf65j5td_2vw1wxy016qc0000gn/T//Rtmpx3qe5t/file1c74b9dbe1c'

Error in if (file.exists(file) == FALSE) if (!missing(asText) && asText ==  : 
  argument is of length zero

Error in parseGRASS("v.extract") : v.extract not parsed

which may tell you that it is related to not finding a python library. However, the actual error can be found by setting legacyExec argument to TRUE in the parseGRASScommand.

> parseGRASS("v.extract", legacyExec=T)

> dyld: Library not loaded: /Library/Frameworks/FFTW3.framework/Versions/3/FFTW3
    Referenced from: /Applications/GRASS-7.3.app/Contents/MacOS/lib/libgrass_gmath.7.3.svn.dylib
    Reason: no suitable image found.
  Error in if (file.exists(file) == FALSE) if (!missing(asText) && asText ==  : 
  argument is of length zero
  Error in parseGRASS("v.extract", legacyExec = T) : v.extract not parsed

This is in fact a dyld problem but related to a library provided by FFTW framework. The FFTW framework is not a requirement for GRASS 7 and also not available (the newer versions) for download in the GRASS page. It comes with the GRASS installation package but R cannot establish a symlink to the directory containing the library, i.e. /Applications/GRASS-7.3.app/Contents/MacOS/lib/FFTW3.framework/Versions/3, although it was added in the DYLD_LIBRARY_PATH. It can also be downloaded from the FFTW official page but the library provided is not identified by GRASS as an architecture matching universal wrapper. The workaround I suggest (found out after struggling for a day) is to simply copy the FFTW framework provided by GRASS from the GRASS directory to the framework directory.

system("cp -Rai /Applications/GRASS-7.3.app/Contents/MacOS/lib/FFTW3.framework /Library/Frameworks")

This will solve the problem!