zk-org / zk

A plain text note-taking assistant
https://zk-org.github.io/zk/
GNU General Public License v3.0
1.7k stars 128 forks source link

Build fails on Apple Silicon #19

Closed mhanberg closed 3 years ago

mhanberg commented 3 years ago

I was attempting to build the project to try it out and ran into this error sqlite3-binding.c:195315:10: fatal error: 'unicode/utypes.h' file not found.

This is on an M1 Mac running macOS 11.2.3 and go version go1.16.2 darwin/arm64

Full Log
$ ./go install
go: downloading github.com/alecthomas/kong v0.2.16-0.20210209082517-405b2f4fd9a4
go: downloading github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
go: downloading github.com/schollz/progressbar/v3 v3.7.4
go: downloading github.com/tj/go-naturaldate v1.3.0
go: downloading github.com/aymerick/raymond v2.0.2+incompatible
go: downloading github.com/mvdan/xurls v1.1.0
go: downloading github.com/yuin/goldmark-meta v1.0.0
go: downloading github.com/AlecAivazis/survey/v2 v2.2.7
go: downloading github.com/fatih/color v1.10.0
go: downloading github.com/mattn/go-sqlite3 v1.14.6
go: downloading github.com/relvacode/iso8601 v1.1.0
go: downloading gopkg.in/djherbis/times.v1 v1.2.0
go: downloading github.com/gosimple/slug v1.9.0
go: downloading github.com/lestrrat-go/strftime v1.0.4
go: downloading github.com/rvflash/elapsed v0.2.0
go: downloading golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: downloading github.com/mattn/go-colorable v0.1.8
go: downloading golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
go: downloading github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
go: downloading github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be
go: downloading github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
go: downloading golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
# github.com/mattn/go-sqlite3
sqlite3-binding.c:195315:10: fatal error: 'unicode/utypes.h' file not found
mickael-menu commented 3 years ago

This header is required by the icu build tag, I think I forgot to mention a dependency in the installation instructions. Could you try after running this with Homebrew?

$ brew install icu4c

I will get an M1 in about two weeks for further testing πŸ‘

mhanberg commented 3 years ago

I ran that and it appears it is already installed πŸ˜…

On Mar 25, 2021, at 5:34 AM, MickaΓ«l Menu @.***> wrote:

This header is required by the icu build tag, I think I forgot to mention a dependency in the installation instructions. Could you try after running this with Homebrew?

$ brew install icu4c I will get an M1 in about two weeks for further testing πŸ‘

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mickael-menu/zk/issues/19#issuecomment-806501949, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKEUEAFNARPUS46NPYZRTLTFL7RLANCNFSM4ZY6P4RQ.

mickael-menu commented 3 years ago

Ha, not a good sign! I found this too from there https://github.com/mattn/go-sqlite3/issues/543

$ brew install icu4c
$ brew link icu4c
$ CGO_CFLAGS="-I/usr/local/opt/icu4c/include" CGO_LDFLAGS="-L/usr/local/opt/icu4c/lib" ./go build

If this doesn't work, I will probably need the M1 to try to find a workaround.

Alternatively, you may be able to build zk with this, but some filtering options might not work properly:

$ CGO_ENABLED=1 go build -tags "fts5"

If you use a feature requiring icu, you will get this error from zk:

zk: error: no such function: REGEXP
mickael-menu commented 3 years ago

I just received my M1 πŸ‘

So the proper command to build was:

$ brew install icu4c
$ GOARCH=arm64 CGO_CFLAGS="-I/opt/homebrew/opt/icu4c/include" CGO_LDFLAGS="-L/opt/homebrew/opt/icu4c/lib" ./go build

@mhanberg I added a new build for the latest release, if you want to check it out: zk-v0.3.0-macos-arm64.zip

danymat commented 2 years ago

Hello, as of today, it seems that doing make on latest release can not compile:

GOARCH=arm64 CGO_CFLAGS="-I/opt/homebrew/opt/icu4c/include" CGO_LDFLAGS="-L/opt/homebrew/opt/icu4c/lib" go build -tags "fts5 icu" -ldflags "-X=main.Version=`git describe --tags --match v[0-9]* 2> /dev/null` -X=main.Build=`git rev-parse --short HEAD`"
# github.com/mickael-menu/zk
ld: warning: directory not found for option '-L/usr/local/opt/icu4c/lib'

Using the command you provided just above seems to work:

GOARCH=arm64 CGO_CFLAGS="-I/opt/homebrew/opt/icu4c/include" CGO_LDFLAGS="-L/opt/homebrew/opt/icu4c/lib" go build
mickael-menu commented 2 years ago

@danymat The warning above is not a fatal error, I always got it on the M1 as well but it seems to run fine.

With the second command a number of features won't work, in particular anything using regexes.

danymat commented 2 years ago

Right, thanks a lot !