Error compiling go app with libmongocrypt on debian 11

I am trying to compile an golang application with the mongo go driver and libmongocrypt in a debian bullseye docker container and running into errors.

libmongocrypt is installed as described here: GitHub - mongodb/libmongocrypt: Required C library for Client Side and Queryable Encryption in MongoDB

libmongocrypt and libbson do seem to be installed properly based on trying a few pkg-config commands.

The failure happens here:

apt-get -y install libmongocrypt-dev libbson-dev pkg-config
go build -mod=vendor -tags cse
# go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:296:16: could not determine kind of name for C.mongocrypt_crypt_shared_lib_version
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:305:20: could not determine kind of name for C.mongocrypt_crypt_shared_lib_version_string
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:169:11: could not determine kind of name for C.mongocrypt_ctx_rewrap_many_datakey_init
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:263:12: could not determine kind of name for C.mongocrypt_ctx_setopt_contention_factor
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:159:11: could not determine kind of name for C.mongocrypt_ctx_setopt_key_material
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:257:12: could not determine kind of name for C.mongocrypt_ctx_setopt_query_type
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:72:3: could not determine kind of name for C.mongocrypt_setopt_append_crypt_shared_lib_search_path
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:64:3: could not determine kind of name for C.mongocrypt_setopt_bypass_query_analysis
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:399:11: could not determine kind of name for C.mongocrypt_setopt_encrypted_field_config_map
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:77:4: could not determine kind of name for C.mongocrypt_setopt_set_crypt_shared_lib_path_override
vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go:81:2: could not determine kind of name for C.mongocrypt_setopt_use_need_kms_credentials_state

Versions:

  • go 1.15
  • go.mongodb.org/mongo-driver v1.11.2 (also tried 1.10.6 and v1.12.0-alpha1, same error)
  • Debian 11
  • libmongocrypt-dev (1.1.0-1)
  • libbson-dev (1.17.6-1)

Can you provide some guidance to debug?

Go driver 1.11.2 requires libmongocrypt 1.5.2 or higher. The required version of libmongocrypt is described here: mongo package - go.mongodb.org/mongo-driver/mongo - Go Packages

To install a newer version of libmongocrypt, one option is to install from the PPA packages described here: GitHub - mongodb/libmongocrypt: Required C library for Client Side and Queryable Encryption in MongoDB

1 Like

Thanks, this solved the issue.

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