I’ve tried way too many ways now to install and make the driver work.
Issue I am facing is: /usr/sbin/apache2: symbol lookup error: /usr/lib/php/20210902/mongodb.so: undefined symbol: ns_initparse
I have latest ubuntu, php8.1, apache2.
phpinfo shows the mongodb present and php.ini has extension=mongodb.so
In the meantime, it’d be helpful if you could attempt compiling the extension from source and share the full output of the ./configure command. This will provide some insight into what is being detected in our environment and the final linker flags used for compilation.
Thanks for looking into this.
Here is the output of ./configure
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether cc accepts -g... yes
checking for cc option to enable C11 features... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20210902 -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext -I/usr/include/php/20210902/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20210902
checking for PHP installed headers prefix... /usr/include/php/20210902
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... gawk
checking whether to enable MongoDB support... yes, shared
checking PHP version... 8.1.2
checking whether to enable developer build flags... no
checking whether to enable code coverage... no
checking whether to compile against system libraries instead of bundled... no
checking whether to use system libbson... no
checking whether to use system libmongoc... no
checking whether to enable client-side encryption... auto
checking for gcc... (cached) cc
checking whether the compiler supports GNU C... (cached) yes
checking whether cc accepts -g... (cached) yes
checking for cc option to enable C11 features... (cached) none needed
checking for g++... g++
checking whether the compiler supports GNU C++... yes
checking whether g++ accepts -g... yes
checking for g++ option to enable C++11 features... none needed
checking accept ARG2 => struct sockaddr ARG3 => socklen_t ... ok
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for typeof syntax and keyword spelling... typeof
checking for __sync_add_and_fetch_4... yes
checking for __sync_add_and_fetch_8... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for _Bool... yes
checking for stdbool.h that conforms to C99... yes
checking for strings.h... (cached) yes
checking whether byte ordering is bigendian... no
checking for strnlen... yes
checking for reallocf... no
checking for syscall... yes
checking for SYS_gettid... yes
checking for snprintf... yes
checking for strlcpy... no
checking for struct timespec... yes
checking for library containing clock_gettime... none required
checking for library containing floor... -lm
checking for gmtime_r... yes
checking for rand_r... yes
checking for arc4random_buf... no
checking if compiler needs -Werror to reject unknown flags... no
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking whether PTHREAD_ONCE_INIT needs braces... no
checking for PHP_MONGODB_SNAPPY... no
checking for snappy_uncompress in -lsnappy... no
checking for snappy-c.h... no
checking for PHP_MONGODB_ZLIB... yes
checking for PHP_MONGODB_ZSTD... no
checking for ZSTD_compress in -lzstd... no
checking for zstd.h... no
checking for res_nsearch... yes
checking for res_ndestroy... no
checking for res_nclose... yes
checking whether to enable SASL for Kerberos authentication... auto
checking for PHP_MONGODB_SASL... no
checking for sasl_client_init in -lsasl2... no
checking for sasl/sasl.h... no
checking which SASL library to use... no
checking whether to enable crypto and TLS... auto
checking deprecated option for OpenSSL library path... auto
checking for cc options needed to detect all undeclared functions... none needed
configure: checking whether OpenSSL is available
checking for PHP_MONGODB_SSL... yes
checking whether ASN1_STRING_get0_data is declared... yes
checking which TLS library to use... openssl
checking whether to use system crypto profile... no
checking deprecated option for whether to use system crypto profile... no
checking whether to enable ICU for SASLPrep with SCRAM-SHA-256 authentication... auto
checking for PHP_MONGODB_ICU... no
checking for shm_open... yes
checking for sched_getcpu... yes
checking for socklen_t... yes
checking for struct sockaddr_storage.ss_family... yes
checking if compiler needs -Werror to reject unknown flags... no
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... (cached) yes
checking if weak symbols are supported... yes
checking which crypto library to use for libmongocrypt... openssl
checking whether byte ordering is bigendian... (cached) no
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) gawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
configure: patching config.h.in
configure: creating ./config.status
mongodb was configured with the following options:
Build configuration:
CFLAGS : -g -O2
Extra CFLAGS :
Developers flags (slow) :
Code Coverage flags (extra slow) :
libmongoc : Bundled (1.11.1-20220829+git623d659f00)
libbson : Bundled (1.11.1-20220829+git623d659f00)
libmongocrypt : Bundled (1.5.2)
LDFLAGS :
EXTRA_LDFLAGS :
MONGODB_SHARED_LIBADD : -lz -lssl -lcrypto
Please submit bugreports at:
https://jira.mongodb.org/browse/PHPC
config.status: creating /home/calnex_admin/mongo-php-driver/src/libmongoc/src/common/common-config.h
config.status: creating /home/calnex_admin/mongo-php-driver/src/libmongoc/src/libbson/src/bson/bson-config.h
config.status: creating /home/calnex_admin/mongo-php-driver/src/libmongoc/src/libbson/src/bson/bson-version.h
config.status: creating /home/calnex_admin/mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-config.h
config.status: creating /home/calnex_admin/mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-version.h
config.status: creating /home/calnex_admin/mongo-php-driver/src/libmongocrypt/src/mongocrypt-config.h
config.status: creating config.h
config.status: executing libtool commands
checking for res_nsearch... yes
checking for res_ndestroy... no
checking for res_nclose... yes
Based on this, the fix in PHPC-2152 should resolve the issue for you. This will be released in 1.14.2, which should be published within the coming week.