From f43d0486419dcafca06450bd5b4b7d919f2e48bc Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Sun, 13 Oct 2024 13:57:34 +0100 Subject: [PATCH] Fix libgsoap linking in src/CMakeLists.txt libgsoap supplies both libgsoap++.a and libgsoapssl++.a however an application should link to one of those libraries not both. An example from gsoap-2.8 samples: With SSL: /usr/bin/clang++ -DLINUX -g -O2 -o json-GitHub json_GitHub-json-GitHub.o json_GitHub-xml-rpc.o json_GitHub-json.o json_GitHub-soapC.o ../../../gsoap/libgsoapssl++.a -lm -lssl -lcrypto -lz Without SSL: /usr/bin/clang++ -DLINUX -g -O2 -o json-currentTimeServer json-currentTimeServer.o xml-rpc.o json.o soapC.o ../../../gsoap/libgsoap++.a -lm -lpthread Right now src/CMakeLists.txt is try to link to both libgsoap++ and libgsoapssl++. /usr/bin/ld: /lib/libgsoapssl++.a(libgsoapssl___a-stdsoap2_ssl_cpp.o): in function `soap_query': (.text+0x1880): multiple definition of `soap_query'; /lib/libgsoap++.a(libgsoap___a-stdsoap2_cpp.o):(.text+0x1890): first defined here /usr/bin/ld: /lib/libgsoapssl++.a(libgsoapssl___a-stdsoap2_ssl_cpp.o): in function `soap_query_decode': (.text+0x18a0): multiple definition of `soap_query_decode'; /lib/libgsoap++.a(libgsoap___a-stdsoap2_cpp.o):(.text+0x18b0): first defined here /usr/bin/ld: /lib/libgsoapssl++.a(libgsoapssl___a-stdsoap2_ssl_cpp.o): in function `soap_query_key': (.text+0x1a50): multiple definition of `soap_query_key'; /lib/libgsoap++.a(libgsoap___a-stdsoap2_cpp.o):(.text+0x1a60): first defined here Change src/CMakeLists.txt so that 1. libgsoap++ is the default library to link 2. libgsoapssl++ is linked to instead if HAVE_OPENSSL is true This means that if openssl is not detected libgsoap++ will be linked otherwise libgsoapssl++ will be linked. Signed-off-by: Bryan O'Donoghue --- src/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7dc9acace..04550c769 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -165,11 +165,15 @@ target_link_libraries(zm PRIVATE zm-core-interface) +set(GSOAP_LIBRARIES ${GSOAP_CXX_LIBRARIES}) +if(HAVE_LIBOPENSSL) + set(GSOAP_LIBRARIES ${GSOAP_SSL_CXX_LIBRARIES}) +endif() + if(GSOAP_FOUND) target_link_libraries(zm PUBLIC - ${GSOAP_CXX_LIBRARIES} - ${GSOAP_SSL_CXX_LIBRARIES} + ${GSOAP_LIBRARIES} ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) endif()