2

I was trying out the godal library and wrote a simple script as follows:

package main

import (
    "github.com/airbusgeo/godal"
)

func main() {
    godal.RegisterAll()
}

Running go run main.go throws the following error

dyld[19569]: Library not loaded: @rpath/libgdal.30.dylib
  Referenced from: /private/var/folders/y5/yh59dj093xn_dz8lm0mhv6lh0000gp/T/go-build1573968352/b001/exe/test
  Reason: tried: '/usr/local/lib/libgdal.30.dylib' (no such file), '/usr/lib/libgdal.30.dylib' (no such file)
signal: abort trap

godal has a dependency on gdal and I had installed it via conda. Due to this, the dylib is located under my conda folder - /Users/ash/miniconda3/lib not /usr/local/lib.

How can I have the program search for libgdal.dylib in /Users/ash/miniconda3/lib instead of /usr/local/lib ?

ashnair1
  • 345
  • 2
  • 9

2 Answers2

0

You could try setting GDAL_LIBRARY_PATH=/Users/ash/miniconda3/lib/libgdal.dylib

You can try this in both the shell where you run go run .... or as an os.Setenv("GDAL_LIBRARY_PATH", "/Users/ash/miniconda3/lib/libgdal.dylib")

decodebytes
  • 411
  • 4
  • 16
0

Add the path to the miniconda3 lib directory to the DYLD_FALLBACK_LIBRARY_PATH environment variable. In your case, that would be:

DYLD_FALLBACK_LIBRARY_PATH=/Users/ash/miniconda3/lib:$DYLD_FALLBACK_LIBRARY_PATH YourGoExecutable

Note: Don't use DYLD_LIBRARY_PATH, as this will clobber existing path resolution, and mostly likely result in unintended trouble down the line.

Will
  • 2,014
  • 2
  • 19
  • 42