We want to use shared libprotobuf.so for many tools to not increase size of 
each binary. 
We know we can build protobuf with -Dprotobuf_BUILD_SHARED_LIBS=ON 
-Dprotobuf_INSTALL_SUPPORTED_FROM_MODULE=ON -Dprotobuf_ABSL_PROVIDER=module 
but then both protobuf and absl are build as shared library.
We need to deliver over 80 libraries.  It would easier if we could only 
deliver single libprotobuf.so file like in the past when protobuf was not 
using absl. 

Is it possible to use static absl libraies and link it libprotobuf.so ? 
I tried firts build abls independentlay with

cmake -S ${ABSL_SOURCE} -B ${ABSL_PROD_DIR} 
-DCMAKE_PREFIX_PATH=${ABSL_PROD_DIR} 
-DCMAKE_INSTALL_PREFIX=${ABSL_PROD_DIR} -DABSL_ENABLE_INSTALL=ON 
-DABSL_USE_EXTERNAL_GOOGLETEST=OFF -DABSL_FIND_GOOGLETEST=OFF

This created static absl libraries.

And then build protobuf  with 
 -DCMAKE_PREFIX_PATH=${ABSL_PROD_DIR}/lib64/cmake/absl 
-Dprotobuf_ABSL_PROVIDER=package-DCMAKE_CXX_STANDARD=14 
-Dprotobuf_BUILD_SHARED_LIBS=ON 

But it fails  with 

[ 36%] Linking CXX shared library libprotobuf.so
/usr/bin/ld: 
/user/adembek/PROD/absl/build/absl_2023_01_25/lib64/libabsl_cord.a(cord.cc.o): 
relocation R_X86_64_32 against `.rodata' can not be used when making a 
shared object; recompile with -fPIC
/usr/bin/ld: 
/user/adembek/PROD/absl/build/absl_2023_01_25/lib64/libabsl_cord.a(cord_analysis.cc.o):
 
relocation R_X86_64_32 against `.rodata' can not be used when making a 
shared object; recompile with -fPIC
/usr/bin/ld: 
/user/adembek/PROD/absl/build/absl_2023_01_25/lib64/libabsl_die_if_null.a(die_if_null.cc.o):
 
relocation R_X86_64_32 against `.rodata' can not be used when making a 
shared object; recompile with -fPIC

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/c383f2ec-65d2-48e0-9465-9c8fd04b0ac0n%40googlegroups.com.

Reply via email to