Build fails on NetBSD

Subject: Build fails on NetBSD

Date: Tue, 13 Oct 2026 16:57:02 +0000

To: notmuch@notmuchmail.org

Cc:

From: Frank Seifferth


Hi everyone,

building the latest version (as of commit f5e58cdb9b) fails on NetBSD with
the following error message:

[...]
CXX  -g -O2 lib/index.o
lib/index.cc: In function ‘void _filter_attachment(notmuch_message_t*, const char*, const char*, const char*, char**, size_t*)’:
lib/index.cc:556:12: error: ‘environ’ was not declared in this scope; did you mean ‘union’?
  556 |     while (environ[num_env])
      |            ^~~~~~~
      |            union
lib/index.cc:566:23: error: ‘environ’ was not declared in this scope; did you mean ‘union’?
  566 |     for (num_env = 0; environ[num_env]; num_env++) {
      |                       ^~~~~~~
      |                       union
gmake: *** [Makefile.local:210: lib/index.o] Error 1

Apparently, environ is implicitly declared on Linux but not on NetBSD.
At least that's how I interpret the following docs:
https://www.gnu.org/software/gnulib/manual/html_node/environ.html.
I am not sure what the proper fix for this issue should look like. The
patch included below at least seems to fix the build process. If someone
understands the issue better than I do, feel free to suggest a better
alternative.


Best

Frank


diff --git a/lib/index.cc b/lib/index.cc
index c1c675b0..e8234920 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -553,6 +553,7 @@ _filter_attachment (notmuch_message_t *message,
     }

     /* set up the environment for the child */
+    extern char **environ;
     while (environ[num_env])
        num_env++;
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: