omniscale / imposm3

Imposm imports OpenStreetMap data into PostGIS
http://imposm.org/docs/imposm3/latest/
Apache License 2.0
723 stars 158 forks source link

Provide instructions to build on Mac #132

Open alewaros opened 7 years ago

alewaros commented 7 years ago

I tried installing this tool on mac but on every step a new error or dependency has popped up. Could you provide instructions on how to use install and build this library in mac?

I'm currently at go get but it says that leveldb and geos can not be found even though I already installed them via homebrew.

olt commented 7 years ago

Can you be more specific? I'm developing on Mac OS and I installed the dependencies with homebrew as well... Does your PATH contain /usr/local/bin?

alewaros commented 7 years ago

After I installed the C++ dependencies with homebrew, I tried to run the go get command, but an error popped saying that it could not find the dependencies. When I print PATH I get this output:

$ echo $PATH
# /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
olt commented 7 years ago

Can you paste the actual error? What is your Go and Mac OS version? (That's what I meant with 'more specific').

alewaros commented 7 years ago

I reinstalled everything and go get seems to create pkg and src directories. go install on the other hand is not creating the bin folder. It just exists, even with verbose flag it doesn't output to console.

My macOS version is 10.12.1 Go version is go1.7.4 darwin/amd64

alewaros commented 7 years ago

If I run go install in the same directory as the main.go file, which is the only way to get some output, I get the following:

# github.com/omniscale/imposm3/vendor/github.com/jmhodges/levigo
../../../github.com/omniscale/imposm3/vendor/github.com/jmhodges/levigo/batch.go:4:11: fatal error: 'leveldb/c.h' file not found
 #include "leveldb/c.h"
          ^
1 error generated.
# github.com/omniscale/imposm3/geom/geos
../../../github.com/omniscale/imposm3/geom/geos/coords.go:5:10: fatal error: 'geos_c.h' file not found
#include "geos_c.h"
         ^
1 error generated.
olt commented 7 years ago

Are these files in /usr/local/include? Did brew returned errors during installation? brew link geos, brew link leveldb, brew doctor...

alewaros commented 7 years ago

Yes, they are. Homebrew returned warning due to python:

Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
  mkdir -p /Users/AJ/Library/Python/2.7/lib/python/site-packages
  echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")'

I ran those lines and try reinstalling it, and the warning was no more. But yeah, they are all installed.

j-la-haye commented 6 years ago

Any update here? I can't get imposm3 to run after following the build instructions from the documentation.

petervojtek commented 5 years ago

I use macos 10.13.6, and followed the instructions and managed to successfully build the binary. the brew commands for dependencies are brew install golang leveldb geos

very-humble-coder commented 4 years ago

@petervojtek I used the same instructions but came up short. I got a compile error using the command `go/src/github.com/omniscale/imposm3/geom/geos/coords.go:5:10: fatal error: 'geos_c.h' file not found

include "geos_c.h"

        ^~~~~~~~~~

1 error generated.`

But after using your brew install golang leveldb geos I got a clean compile. Thanks for leaving this behind.

konskoehler commented 2 years ago

Not working under macos 12.1 with

I tried to downgrade go, did not have any effect.

Any ideas? :(

adamakhtar commented 2 years ago

Its not building on my M1 Mac either. I believe this is due to brew installing libraries in /opt/homebrew/Cellar/ on ARM machines instead of usr/local/var on intel machines.

These are the locations & versions of Go, GEOS and LevelDB on my machine:

/opt/homebrew/Cellar/go/1.17.6 /opt/homebrew/Cellar/geos/3.10.2 /opt/homebrew/Cellar/leveldb/1.23

This is the full error output

mkdir go
go get github.com/omniscale/imposm3
go install github.com/omniscale/imposm3/cmd/imposm@v0.11.1

go: downloading github.com/omniscale/go-osm v0.2.1
go: downloading github.com/pkg/errors v0.8.0
go: downloading github.com/jmhodges/levigo v0.0.0-20161115193449-c42d9e0ca023
go: downloading github.com/lib/pq v1.8.0
go: downloading gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7
go: downloading github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415
go: downloading gopkg.in/fsnotify.v1 v1.4.2
go: downloading golang.org/x/sys v0.0.0-20171114162044-bf42f188b9bc
# github.com/jmhodges/levigo
pkg/mod/github.com/jmhodges/levigo@v0.0.0-20161115193449-c42d9e0ca023/batch.go:4:11: fatal error: 'leveldb/c.h' file not found
 #include "leveldb/c.h"
          ^~~~~~~~~~~~~
1 error generated.
# github.com/omniscale/imposm3/geom/geos
pkg/mod/github.com/omniscale/imposm3@v0.11.1/geom/geos/coords.go:5:10: fatal error: 'geos_c.h' file not found
#include "geos_c.h"
         ^~~~~~~~~~
1 error generated.

Can anyone suggest how I work around this to create a build?

trytuna commented 2 years ago

Any update on this? I am having the same issue as @adamakhtar described.

EDIT:

I found a solution to make it compile:

brew install go leveldb geos
CGO_CFLAGS="-I/opt/homebrew/Cellar/leveldb/1.23/include -I/opt/homebrew/Cellar/geos/3.10.2/include" CGO_LDFLAGS="-L/opt/homebrew/Cellar/leveldb/1.23/lib -L/opt/homebrew/Cellar/geos/3.10.2/lib" make imposm
% file imposm
imposm: Mach-O 64-bit executable arm64
trytuna commented 2 years ago

I did a PR on Homebrew/homebrew-core that includes a imposm3 Formula. Now it's just a matter of brew install imposm3 to get it on macOS

francois2metz commented 2 years ago

This issue can now be fixed.