Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error locating libgdal.dylib in macos #98

Open
ashnair1 opened this issue Aug 7, 2022 · 4 comments
Open

Error locating libgdal.dylib in macos #98

ashnair1 opened this issue Aug 7, 2022 · 4 comments

Comments

@ashnair1
Copy link

ashnair1 commented Aug 7, 2022

I was trying out the godal library (on my M1 Mac) 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 ?

Had raised this question in StackOverflow previously but didn't get any solutions to this issue. Link - here

@eval-apply
Copy link

godal makes use of pkg-config to pass ldflags to cgo, so you will need to let it know where the GDAL pkg-config path is. I don't know the specific install location when using miniconda, but once you know the path something like this would work:

PKG_CONFIG_PATH=//Users/ash/miniconda3/lib/gdal/pkgconfig go run main.go

@ashnair1
Copy link
Author

ashnair1 commented Aug 8, 2022

I had already set PKG_CONFIG_PATH prior to running the command. The error still occurs.

$ echo $PKG_CONFIG_PATH
/Users/ash/miniconda3/lib/pkgconfig

$ ls $PKG_CONFIG_PATH | grep gdal.pc
gdal.pc

$ go run main.go
dyld[28793]: Library not loaded: @rpath/libgdal.30.dylib
  Referenced from: /private/var/folders/y5/yh59dj093xn_dz8lm0mhv6lh0000gp/T/go-build3191999631/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

@eval-apply
Copy link

ok then you'd need to tell it where to find the dynamic library at runtime, something like LD_LIBRARY_PATH=/Users/ash/miniconda3/lib go run main.go perhaps? I'm just guessing that's where miniconda libs live.

@ashnair1
Copy link
Author

ashnair1 commented Aug 9, 2022

You mean DYLD_LIBRARY_PATH? This is for MacOS. I tried setting those and the problem persists.

Btw, that is indeed where miniconda libs live

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants