Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build against system libcurl #77

Closed
amadio opened this issue Oct 10, 2021 · 1 comment
Closed

Cannot build against system libcurl #77

amadio opened this issue Oct 10, 2021 · 1 comment

Comments

@amadio
Copy link
Contributor

amadio commented Oct 10, 2021

The reason is that the library is called libcurl.so and needs to be linked as -lcurl not -llibcurl. However, the build system has no code to support the case in which the embedded library is not used. See the error below.

FAILED: src/libdavix.so.0.8.0 
: && /usr/bin/x86_64-pc-linux-gnu-g++ -fPIC -march=native -O2 -pipe -std=c++11  -Wl,-O1 -Wl,--as-needed -shared -Wl,-soname,libdavix.so.0 -o src/libdavix.so.0.8.0 deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_207.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_acl3744.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_alloc.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_auth.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_basic.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_compress.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_dates.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_i18n.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_locks.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_md5.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_ntlm.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_oldacl.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_pkcs11.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_props.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_redirect.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_request.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_session.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_socket.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_socks.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_sspi.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_string.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_uri.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_utils.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_xml.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_xmlreq.c.o deps/libneon/CMakeFiles/LibNeonObjects.dir/src/ne_openssl.c.o src/CMakeFiles/libdavix.dir/auth/davix_openssl.cpp.o src/CMakeFiles/libdavix.dir/auth/davixauth.cpp.o src/CMakeFiles/libdavix.dir/auth/davixx509cred.cpp.o src/CMakeFiles/libdavix.dir/backend/BackendRequest.cpp.o src/CMakeFiles/libdavix.dir/backend/SessionFactory.cpp.o src/CMakeFiles/libdavix.dir/backend/StandaloneNeonRequest.cpp.o src/CMakeFiles/libdavix.dir/core/ContentProvider.cpp.o src/CMakeFiles/libdavix.dir/core/RedirectionResolver.cpp.o src/CMakeFiles/libdavix.dir/curl/CurlSession.cpp.o src/CMakeFiles/libdavix.dir/curl/CurlSessionFactory.cpp.o src/CMakeFiles/libdavix.dir/curl/HeaderlineParser.cpp.o src/CMakeFiles/libdavix.dir/curl/ResponseBuffer.cpp.o src/CMakeFiles/libdavix.dir/curl/StandaloneCurlRequest.cpp.o src/CMakeFiles/libdavix.dir/deprecated/httpcachetoken.cpp.o src/CMakeFiles/libdavix.dir/file/davfile.cpp.o src/CMakeFiles/libdavix.dir/file/davposix.cpp.o src/CMakeFiles/libdavix.dir/fileops/AzureIO.cpp.o src/CMakeFiles/libdavix.dir/fileops/chain_factory.cpp.o src/CMakeFiles/libdavix.dir/fileops/davix_reliability_ops.cpp.o src/CMakeFiles/libdavix.dir/fileops/davmeta.cpp.o src/CMakeFiles/libdavix.dir/fileops/fileutils.cpp.o src/CMakeFiles/libdavix.dir/fileops/httpiochain.cpp.o src/CMakeFiles/libdavix.dir/fileops/httpiovec.cpp.o src/CMakeFiles/libdavix.dir/fileops/iobuffmap.cpp.o src/CMakeFiles/libdavix.dir/fileops/S3IO.cpp.o src/CMakeFiles/libdavix.dir/fileops/SwiftIO.cpp.o src/CMakeFiles/libdavix.dir/hooks/davix_hooks.cpp.o src/CMakeFiles/libdavix.dir/libs/alibxx/chrono/timepoint.cpp.o src/CMakeFiles/libdavix.dir/libs/alibxx/crypto/base64.cpp.o src/CMakeFiles/libdavix.dir/libs/alibxx/crypto/hmacsha.cpp.o src/CMakeFiles/libdavix.dir/libs/alibxx/str/format.cpp.o src/CMakeFiles/libdavix.dir/libs/datetime/datetime_utils.cpp.o src/CMakeFiles/libdavix.dir/modules/modules_profiles.cpp.o src/CMakeFiles/libdavix.dir/neon/neonrequest.cpp.o src/CMakeFiles/libdavix.dir/neon/neonsession.cpp.o src/CMakeFiles/libdavix.dir/neon/neonsessionfactory.cpp.o src/CMakeFiles/libdavix.dir/params/davixrequestparams.cpp.o src/CMakeFiles/libdavix.dir/request/httprequest.cpp.o src/CMakeFiles/libdavix.dir/status/DavixStatus.cpp.o src/CMakeFiles/libdavix.dir/status/davixstatusrequest.cpp.o src/CMakeFiles/libdavix.dir/utils/checksum_extractor.cpp.o src/CMakeFiles/libdavix.dir/utils/CompatibilityHacks.cpp.o src/CMakeFiles/libdavix.dir/utils/davix_azure_utils.cpp.o src/CMakeFiles/libdavix.dir/utils/davix_gcloud_utils.cpp.o src/CMakeFiles/libdavix.dir/utils/davix_logger.cpp.o src/CMakeFiles/libdavix.dir/utils/davix_misc_utils.cpp.o src/CMakeFiles/libdavix.dir/utils/davix_cs3_utils.cpp.o src/CMakeFiles/libdavix.dir/utils/davix_s3_utils.cpp.o src/CMakeFiles/libdavix.dir/utils/davix_swift_utils.cpp.o src/CMakeFiles/libdavix.dir/utils/simple_get_pass.cpp.o src/CMakeFiles/libdavix.dir/utils/stringutils.cpp.o src/CMakeFiles/libdavix.dir/utils/davixuri.cpp.o src/CMakeFiles/libdavix.dir/xml/azurepropparser.cpp.o src/CMakeFiles/libdavix.dir/xml/davdeletexmlparser.cpp.o src/CMakeFiles/libdavix.dir/xml/davix_ptree.cpp.o src/CMakeFiles/libdavix.dir/xml/davpropxmlparser.cpp.o src/CMakeFiles/libdavix.dir/xml/davxmlparser.cpp.o src/CMakeFiles/libdavix.dir/xml/metalinkparser.cpp.o src/CMakeFiles/libdavix.dir/xml/s3deleteparser.cpp.o src/CMakeFiles/libdavix.dir/xml/S3MultiPartInitiationParser.cpp.o src/CMakeFiles/libdavix.dir/xml/s3propparser.cpp.o src/CMakeFiles/libdavix.dir/xml/swiftpropparser.cpp.o src/CMakeFiles/libdavix.dir/davixcontext.cpp.o  -llibcurl  -lssl  -lcrypto  -lxml2  -lpthread  -luuid  -lz && :
/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -llibcurl
collect2: error: ld returned 1 exit status

For now, in order to package Davix, I am using the following patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c65ed46b..35950a9a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -117,6 +117,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAG_ENABLE}")
 if(EMBEDDED_LIBCURL)
   include(buildCurl REQUIRED)
   buildCurl()
+else()
+  find_package(CURL REQUIRED)
 endif()
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/deps/libneon/src/ ${UUID_INCLUDE_DIRS})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 79a8858b..53455abb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -108,7 +108,7 @@ add_library(libdavix  SHARED ${DAVIX_SOURCES} )
 
 target_include_directories(libdavix PRIVATE ${DAVIX_INTERNAL_INCLUDES} )
 target_link_libraries(libdavix
-  PRIVATE libcurl
+  PRIVATE CURL::libcurl
   PUBLIC ${LIBSSL_PKG_LIBRARIES}
          ${LIBXML2_LIBRARIES}
          ${CMAKE_THREAD_LIBS_INIT}
@@ -146,7 +146,7 @@ set_target_properties(libdavix_static PROPERTIES
 target_include_directories(libdavix_static PRIVATE ${DAVIX_INTERNAL_INCLUDES} )
 
 target_link_libraries(libdavix_static
-  PRIVATE libcurl
+  PRIVATE CURL::libcurl
   PUBLIC  ${OPENSSL_LIBRARIES}
           ${CMAKE_THREAD_LIBS_INIT}
           dl ${UUID_LIBRARIES}

However, that is not a full solution, as that breaks the case with embedded libcurl. It would be nice to have davix support building against all external libraries rather than only the embedded ones. Thanks!

@amadio
Copy link
Contributor Author

amadio commented Sep 16, 2022

Fixed by 78c00e1.

@amadio amadio closed this as completed Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant