[GIS] How to solve an installation problem requiring “liblwgeom” to work with “shp2pgsql”

postgisshapefile

I am trying to import shapefile to PostGIS. I have problem configuring shp2pgsql.

I am getting this error :

dyld: Library not loaded: @loader_path/../lib/liblwgeom-2.1.1.dylib
  Referenced from: /Library/PostgreSQL/9.3/bin/shp2pgsql
  Reason: image not found

I am trying to explore where the command is:

macbook$ locate shp2pgsql
/Library/PostgreSQL/9.3/PostGIS/man/shp2pgsql.1
/Library/PostgreSQL/9.3/bin/shp2pgsql


macbook$ ls /usr/bin/shp2pgsql
/usr/bin/shp2pgsql

I installed "liblwgeom" using homebrew,

macbook$ ls /usr/local/opt/liblwgeom/lib
liblwgeom-2.1.1.dylib

Do you have any idea how to resolve this issue .

Best Answer

One way to solve this is to create a symlink /Library/PostgreSQL/9.3/lib/liblwgeom-2.1.1.dylib that points to /usr/local/opt/liblwgeom/lib/liblwgeom-2.1.1.dylib.

There are other ways (setting library path environment variables, using homebrew for everything), but this is probably the most efficient. Note that if you do need to upgrade lwgeom, you may need to create a new symlink.

Related Question