Re: macOS and go language bindings

Subject: Re: macOS and go language bindings

Date: Sun, 26 Nov 2023 14:11:26 +0100

To: Peter Lawrence

Cc: notmuch@notmuchmail.org

From: Reto


Hi both,
I realize I am a bit late to the party, nevertheless here's some information.

> I'm trying to build an email client (aerc) with support for notmuch
> on macOS. aerc is written in go. I can't find an aerc package for brew
> which includes notmuch headers/library files.  Where can I get these
> language bindings and how do I "install" them, or where do I place them
> in the aerc source directory to get the notmuch library built and then
> accessible to aerc?

You are confusing things here.
Aerc wrote their own go notmuch bindings which uses the C library directly.
Stuff in contrib/ doesn't matter whatsoever.

So you don't install the "language bindings", it's part of the aerc source
already.

All you need to make sure is that the C compiler go invokes finds the dependencies.
Meaning you need libnotmuch installed or build from source.

> GO111MODULE
> 	Controls whether the go command runs in module-aware mode or GOPATH mode.
> 	May be "off", "on", or "auto".
> 	See https://golang.org/ref/mod#mod-commands.
> 
> So, I set my GO111MODULE to off with this command:
>     go env -w GO111MODULE="off"

Do not mess with that, aerc is a proper module aware source.
`Go build` will fetch the go dependencies it needs automatically.

> I wonder if anyone proficient with Go might know how to get the source
> to build against a Go 1.20+ version?

If by source you mean aerc, make will do (within their source tree).
However, you need to make sure that your C compiler is setup properly.

Go will execute a C compiler / linker as usual.
In your case, you basically need to setup 2 things:

	1) notmuch.h in some include dir, normally /usr/include/notmuch.h or some such,
	which is needed by the compiler.

	2) libnotmuch.so, which is normally located at /usr/lib/libnotmuch.so or some such,
	which is needed by the linker.

I have no clue where brew stores those things, shouldn't be too hard to figure out though.
Assuming that's not in some standard dir your C compiler / linker already look (else the build would work)
you can override that by setting some env vars.

CGO_CFLAGS: set that to "-I/usr/include" where /usr/include is the folder where notmuch.h resides
CGO_LDFLAGS: set that tho "-L/usr/lib" where /usr/lib is the folder where libnotmuch.so resides.

That will make the C side of things do what you expect.
The rest is handled by go.

Cheers,
Reto
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: