Closed ladislavmacoun closed 3 years ago
I've used the curl project as an inspiration (https://github.com/curl/curl/blob/master/lib/CMakeLists.txt)
Without this patch, the build fails with
[ 60%] Linking CXX shared library ../../../lib/libelasticlient.so
/usr/bin/ld: ../../../lib/libcurl.a(formdata.c.o): relocation R_X86_64_PC32 against symbol `stdin@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../../lib/libcurl.a(mprintf.c.o): relocation R_X86_64_PC32 against symbol `stdout@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../../lib/libcurl.a(setopt.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../../lib/libcurl.a(cookie.c.o): relocation R_X86_64_PC32 against symbol `stdin@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../../lib/libcurl.a(url.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
With:
Scanning dependencies of target elasticlient
make[3]: Leaving directory '/xxx/build'
make[3]: Entering directory '/xxx/build'
[ 59%] Building CXX object external/elasticlient/src/CMakeFiles/elasticlient.dir/client.cc.o
[ 59%] Building CXX object external/elasticlient/src/CMakeFiles/elasticlient.dir/bulk.cc.o
[ 60%] Building CXX object external/elasticlient/src/CMakeFiles/elasticlient.dir/scroll.cc.o
[ 60%] Building CXX object external/elasticlient/src/CMakeFiles/elasticlient.dir/logging.cc.o
[ 61%] Linking CXX static library ../../../lib/libelasticlient.a
make[3]: Leaving directory '/xxx/build'
Thank you for the MR. It will be really good to have the possibility to build elasticlient statically. However we checked it today and there will be little bit more work to have this option fully functional. I.e. without some necessary modifications there is no possible now to build elasticlient statically using jsoncpp library. But that's fine, we will come out of your merge request and make these other modifications to have the possibility to build library statically.
The library will be build depending on the BUILD_SHARED_LIBS1 flag. This enables to build and link this library statically.
Signed-off-by: Ladislav Macoun ladislavmacoun@gmail.com