Hello, I am trying to build the C Driver for MongoDB version 1.21.1 and I am getting an error.
I’m building this driver in Docker with Ubuntu 16.04, CMake 3.17, and GNU 5.4.0.
My building commands:
mkdir -p /deps \
&& cd /deps \
&& apt-get install -y libsasl2-dev wget \
&& LATEST_RELEASE="https://api.github.com/repos/mongodb/mongo-c-driver/releases/latest" \
&& TAG=$(curl --silent $LATEST_RELEASE | grep -Po '"tag_name": "\K.*(?=")') \
&& wget "https://github.com/mongodb/mongo-c-driver/releases/download/$TAG/mongo-c-driver-$TAG.tar.gz" \
&& tar xzf "mongo-c-driver-$TAG.tar.gz" \
&& cd "mongo-c-driver-$TAG" \
&& mkdir cmake-build && cd cmake-build \
&& cmake \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_ICU=OFF \
-DOPENSSL_USE_STATIC_LIBS=TRUE \
-DCMAKE_PREFIX_PATH="/opt/openssl" \
-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF .. \
&& make -j$(nproc) install
And starting from the last release (I guess), I’m getting this error:
#12 11.26 [ 7%] Building C object src/libbson/CMakeFiles/bson_shared.dir/src/bson/bson-writer.c.o
#12 11.28 /deps/mongo-c-driver-1.21.0/src/libbson/src/bson/bson-iter.c: In function 'bson_iter_visit_all':
#12 11.28 [ 7%] Building C object src/libbson/CMakeFiles/bson_shared.dir/src/jsonsl/jsonsl.c.o
#12 11.28 /deps/mongo-c-driver-1.21.0/src/libbson/src/bson/bson-iter.c:2144:11: error: 'key' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#12 11.28 bson_utf8_validate (key, strlen (key), false)) {
#12 11.28 ^
#12 11.28 /deps/mongo-c-driver-1.21.0/src/libbson/src/bson/bson-iter.c:2145:10: error: 'bson_type' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#12 11.28 visitor->visit_unsupported_type (iter, key, bson_type, data);
#12 11.28 ^
#12 11.29 [ 8%] Building C object src/libbson/CMakeFiles/bson_static.dir/src/bson/bson-utf8.c.o
#12 11.31 /deps/mongo-c-driver-1.21.0/src/libbson/src/bson/bson-iter.c: In function 'bson_iter_visit_all':
#12 11.31 /deps/mongo-c-driver-1.21.0/src/libbson/src/bson/bson-iter.c:2144:11: error: 'key' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#12 11.31 bson_utf8_validate (key, strlen (key), false)) {
#12 11.31 ^
#12 11.31 /deps/mongo-c-driver-1.21.0/src/libbson/src/bson/bson-iter.c:2145:10: error: 'bson_type' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#12 11.31 visitor->visit_unsupported_type (iter, key, bson_type, data);
#12 11.31 ^
#12 11.31 [ 8%] Building C object src/libbson/CMakeFiles/bson_shared.dir/__/common/common-b64.c.o
#12 11.33 [ 9%] Building C object src/libbson/CMakeFiles/bson_shared.dir/__/common/common-md5.c.o
#12 11.35 [ 9%] Building C object src/libbson/CMakeFiles/bson_static.dir/src/bson/bson-value.c.o
#12 11.38 [ 9%] Building C object src/libbson/CMakeFiles/bson_shared.dir/__/common/common-thread.c.o
#12 11.42 [ 9%] Building C object src/libbson/CMakeFiles/bson_static.dir/src/bson/bson-version-functions.c.o
#12 11.44 [ 9%] Building C object src/libbson/CMakeFiles/bson_static.dir/src/bson/bson-writer.c.o
#12 11.45 cc1: some warnings being treated as errors
#12 11.46 [ 9%] Building C object src/libbson/CMakeFiles/bson_static.dir/src/jsonsl/jsonsl.c.o
#12 11.46 src/libbson/CMakeFiles/bson_shared.dir/build.make:183: recipe for target 'src/libbson/CMakeFiles/bson_shared.dir/src/bson/bson-iter.c.o' failed
#12 11.46 make[2]: *** [src/libbson/CMakeFiles/bson_shared.dir/src/bson/bson-iter.c.o] Error 1
#12 11.46 make[2]: *** Waiting for unfinished jobs....
#12 11.46 [ 10%] Building C object src/libbson/CMakeFiles/bson_static.dir/__/common/common-b64.c.o
#12 11.48 cc1: some warnings being treated as errors
#12 11.48 src/libbson/CMakeFiles/bson_static.dir/build.make:183: recipe for target 'src/libbson/CMakeFiles/bson_static.dir/src/bson/bson-iter.c.o' failed
#12 11.48 make[2]: *** [src/libbson/CMakeFiles/bson_static.dir/src/bson/bson-iter.c.o] Error 1
#12 11.48 make[2]: *** Waiting for unfinished jobs....
#12 11.48 [ 10%] Building C object src/libbson/CMakeFiles/bson_static.dir/__/common/common-md5.c.o
#12 11.74 CMakeFiles/Makefile2:1677: recipe for target 'src/libbson/CMakeFiles/bson_shared.dir/all' failed
#12 11.74 make[1]: *** [src/libbson/CMakeFiles/bson_shared.dir/all] Error 2
#12 11.74 make[1]: *** Waiting for unfinished jobs....
#12 11.77 make[1]: *** [src/libbson/CMakeFiles/bson_static.dir/all] Error 2
#12 11.77 CMakeFiles/Makefile2:1569: recipe for target 'src/libbson/CMakeFiles/bson_static.dir/all' failed
#12 11.77 make: *** [all] Error 2
#12 11.77 Makefile:179: recipe for target 'all' failed
Any help would be appreciated!