Unable to build Go app with cse tag

I have followed the steps here to install libmongocrypt and added the cse tag to my go build.

brew info libmongocrypt
==> mongodb/brew/libmongocrypt: stable 1.8.2, HEAD
C library for Client Side Encryption
https://github.com/mongodb/libmongocrypt
/opt/homebrew/Cellar/libmongocrypt/1.8.2 (44 files, 9.4MB) *
  Built from source on 2023-11-07 at 11:28:05
From: https://github.com/mongodb/homebrew-brew/blob/HEAD/Formula/libmongocrypt.rb
License: Apache-2.0
==> Dependencies
Build: cmake ✔, mongo-c-driver ✔
==> Options
--HEAD
	Install HEAD version

Build results:

go build -ldflags "-X 'main.version=f0205c2409aa47ce7ac836784f364468af074380'" -tags cse -o /path/to/go/project/bin/apiserver cmd/apiserver/apiserver.go
# command-line-arguments
/usr/local/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
ld: warning: search path '/opt/homebrew/Cellar/libmongocrypt/1.8.1/lib' not found
ld: library 'mongocrypt' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This was working for me before but I believe i installed libmongocrypt before the release on Sept 5. I was helping a team member get set up so I uninstalled to walk through the installation with them and now it’s failing for both of us.

Our go-mongodriver version is v1.11.7

Any suggestions?

Also here is the pkg-config debug for libmongocrypt:

> pkg-config --debug --cflags --libs libmongocrypt

Error printing enabled by default due to use of output options besides --exists, --atleast/exact/max-version or --list-all. Value of --silence-errors: 0
Error printing enabled
Adding virtual 'pkg-config' package to list of known packages
Looking for package 'libmongocrypt'
Looking for package 'libmongocrypt-uninstalled'
Reading 'libmongocrypt' from file '/opt/homebrew/lib/pkgconfig/libmongocrypt.pc'
Parsing package file '/opt/homebrew/lib/pkgconfig/libmongocrypt.pc'
  line>Name: mongocrypt
  line>Description: The libmongocrypt client-side field level encryption library.
  line>Version: 1.8.2
  line>Requires:
  line>Requires.private:
  line>prefix=/opt/homebrew/Cellar/libmongocrypt/1.8.2
 Variable declaration, 'prefix' has value '/opt/homebrew/Cellar/libmongocrypt/1.8.2'
  line>includedir=${prefix}/include/mongocrypt
 Variable declaration, 'includedir' has value '/opt/homebrew/Cellar/libmongocrypt/1.8.2/include/mongocrypt'
  line>libdir=${prefix}/lib
 Variable declaration, 'libdir' has value '/opt/homebrew/Cellar/libmongocrypt/1.8.2/lib'
  line>Libs: -L${libdir} -lmongocrypt
  line>Cflags: -I${includedir}
Path position of 'libmongocrypt' is 1
Adding 'libmongocrypt' to list of known packages
 post-recurse: libmongocrypt
adding CFLAGS_OTHER string ""
 post-recurse: libmongocrypt
 original: libmongocrypt
   sorted: libmongocrypt
adding CFLAGS_I string "-I/opt/homebrew/Cellar/libmongocrypt/1.8.2/include/mongocrypt "
 post-recurse: libmongocrypt
 original: libmongocrypt
   sorted: libmongocrypt
adding LIBS_L string "-L/opt/homebrew/Cellar/libmongocrypt/1.8.2/lib "
 post-recurse: libmongocrypt
adding LIBS_OTHER | LIBS_l string "-lmongocrypt "
returning flags string "-I/opt/homebrew/Cellar/libmongocrypt/1.8.2/include/mongocrypt -L/opt/homebrew/Cellar/libmongocrypt/1.8.2/lib -lmongocrypt"
-I/opt/homebrew/Cellar/libmongocrypt/1.8.2/include/mongocrypt -L/opt/homebrew/Cellar/libmongocrypt/1.8.2/lib -lmongocrypt

This was resolved by running go clean -cache as described in this Github issue

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.