Details
-
Bug
-
Resolution: Fixed
-
Unknown
-
1.25.0
-
None
-
None
Description
When upgrading the C driver dependency in the C++ driver to 1.25.0, the following error occurred building an example project (example task):
[2023/11/08 12:14:47.192] Example bsoncxx/pkg-config/static failed
|
[2023/11/08 12:14:47.193] -DBSONCXX_STATIC -pthread -DBSON_STATIC -I/data/mci/e9fe78cca062add974871e9ff01524c3/mongoc/include/libbson-1.0 -I/data/mci/e9fe78cca062add974871e9ff01524c3/mongo-cxx-driver/build/install/include/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc -I/data/mci/e9fe78cca062add974871e9ff01524c3/mongo-cxx-driver/build/install/include/bsoncxx/v_noabi -I/data/mci/e9fe78cca062add974871e9ff01524c3/mongo-cxx-driver/build/install/include
|
[2023/11/08 12:14:47.193] /usr/bin/ld: /data/mci/e9fe78cca062add974871e9ff01524c3/mongoc/lib/libbson-static-1.0.a(common-b64.c.o): undefined reference to symbol 'pthread_once@@GLIBC_2.2.5'
|
[2023/11/08 12:14:47.193] /usr/bin/ld: //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
|
[2023/11/08 12:14:47.193] collect2: error: ld returned 1 exit status
|
Here are the contents of libbson-1.0-static.pc on C driver 1.25.0 built on Ubuntu 18.04:
# pkg-config .pc file generated by CMake 3.25.3 for libbson-1.25.0. DO NOT EDIT!
|
prefix=/home/ubuntu/code/tasks/mongo-cxx-driver-release-3.9.0/mongoc
|
exec_prefix=${prefix}
|
libdir=${exec_prefix}/lib
|
|
|
Name: libbson
|
Description: The libbson BSON serialization library
|
Version: 1.25.0
|
|
|
Libs: -L${libdir} -lbson-static-1.0 -L/usr/lib/x86_64-linux-gnu -lrt
|
Cflags: -pthread -DBSON_STATIC -I${prefix}/include/libbson-1.0
|
I expect -pthread may need to be included in Libs. A similar change may be needed for libmongoc-1.0-static.pc.
The failing task compiles and links in separate commands:
$CXX $CXXFLAGS -Wall -Wextra -Werror -std="c++${CXX_STANDARD}" -c -o hello_bsoncxx.o ../../../hello_bsoncxx.cpp $(pkg-config --cflags libbsoncxx-static)
|
$CXX $LDFLAGS -std="c++${CXX_STANDARD}" -o hello_bsoncxx hello_bsoncxx.o $(pkg-config --libs libbsoncxx-static)
|
A simple workaround is to set -pthread flag in the link command. This workaround was applied in https://github.com/mongodb/mongo-cxx-driver/pull/1056.