CentOS7,
cmake version 3.17.2
gcc version 7.5.0 (GCC)
I follow this page to install my mongo-c-driver.But no way can success.
link address:
http://mongoc.org/libmongoc/current/installing.html
FIRST way:
I run this command:
yum install mongo-c-driver
result is:
No package mongo-c-driver available.
Error: Nothing to do
install failed…
SECOND way:
I download rpm mongo-c-driver-1.16.2-2.fc32.src.rpm
when I run :
[henry@localhost mongo]$ rpm -ivh mongo-c-driver-1.16.2-2.fc32.src.rpm
Updating / installing...
1:mongo-c-driver-1.16.2-2.fc32 ################################# [100%]
BUT, I cant find any mongoc.h in any where…
find / -xdev -name “mongoc.h”
INSTALL FAILED…again…
THIRD way:
I download release source code.
https://github.com/mongodb/mongo-c-driver/releases/download/1.16.2/mongo-c-driver-1.16.2.tar.gz
mongo-c-driver-1.16.2.tar.gz
I use cmake to build:
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DCMAKE_BUILD_TYPE=Release -fPIC …
-- Looking for include file unistd.h
-- Looking for include file unistd.h - found
-- Looking for include file stdarg.h
-- Looking for include file stdarg.h - found
-- Searching for compression library zstd
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.27.1")
-- Checking for module 'libzstd'
-- No package 'libzstd' found
-- Not found
-- Found OpenSSL: /usr/local/ssl/lib/libcrypto.a (found version "1.0.2p")
-- Looking for ASN1_STRING_get0_data in /usr/local/ssl/lib/libcrypto.a
-- Looking for ASN1_STRING_get0_data in /usr/local/ssl/lib/libcrypto.a - not found
-- Searching for sasl/sasl.h
-- Not found (specify -DCMAKE_INCLUDE_PATH=/path/to/sasl/include for SASL support)
-- Searching for libsasl2
-- Not found (specify -DCMAKE_LIBRARY_PATH=/path/to/sasl/lib for SASL support)
-- Check size of socklen_t
-- Check size of socklen_t - done
-- Looking for res_nsearch
-- Looking for res_nsearch - found
-- Looking for res_ndestroy
-- Looking for res_ndestroy - not found
-- Looking for res_nclose
-- Looking for res_nclose - found
-- Looking for sched_getcpu
-- Looking for sched_getcpu - not found
-- Detected parameters: accept (int, struct sockaddr *, socklen_t *)
-- Searching for compression library header snappy-c.h
-- Not found (specify -DCMAKE_INCLUDE_PATH=/path/to/snappy/include for Snappy compression)
Searching for libmongocrypt
-- libmongocrypt not found. Configuring without Client-Side Field Level Encryption support.
-- Performing Test MONGOC_HAVE_SS_FAMILY
-- Performing Test MONGOC_HAVE_SS_FAMILY - Success
-- Compiling against OpenSSL
-- SASL disabled
-- Configuring done
-- Generating done
-- Build files have been written to: /home/henry/packageRoot/mongo/mongo-c-driver-1.16.2/cmake-build
I the end , it print done. I think i build success.
Then I run:
make
2 Errors accour. The content is below:
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(bn_sqrt.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(bn_exp2.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(bn_gf2m.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(ec_print.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(rsa_gen.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(rsa_saos.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(rsa_pss.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(dsa_gen.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(dh_gen.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(a_set.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(bio_ndef.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(asn_mime.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(bio_b64.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(bio_asn1.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [src/libmongoc/libmongoc-1.0.so.0.0.0] Error 1
make[1]: *** [src/libmongoc/CMakeFiles/mongoc_shared.dir/all] Error 2
make: *** [all] Error 2
I search a lot . They told to add -fPIC to the CMakeCache.txt.
but I realy add .Then run make, but also failed…
(I am chinese, my English is not good…)
Please Give me some advices about how to install mongo-c-driver on CentOS7…
Thanks VERY MUCH !