From 9dd2ab720e4c95e987732df35b164b465a74cf19 Mon Sep 17 00:00:00 2001 From: "mattdr.breakpad@gmail.com" Date: Wed, 29 Jan 2014 20:34:07 +0000 Subject: Support statically-linked libcurl for HTTP uploads in Linux https://breakpad.appspot.com/1064002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1277 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/linux/http_upload.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/linux/http_upload.cc b/src/common/linux/http_upload.cc index fead76e9..d49f2276 100644 --- a/src/common/linux/http_upload.cc +++ b/src/common/linux/http_upload.cc @@ -70,7 +70,17 @@ bool HTTPUpload::SendRequest(const string &url, if (!CheckParameters(parameters)) return false; - void *curl_lib = dlopen("libcurl.so", RTLD_NOW); + // We may have been linked statically; if curl_easy_init is in the + // current binary, no need to search for a dynamic version. + void* curl_lib = dlopen(NULL, RTLD_NOW); + if (!curl_lib || dlsym(curl_lib, "curl_easy_init") == NULL) { + dlerror(); // Clear dlerror before attempting to open libraries. + dlclose(curl_lib); + curl_lib = NULL; + } + if (!curl_lib) { + curl_lib = dlopen("libcurl.so", RTLD_NOW); + } if (!curl_lib) { if (error_description != NULL) *error_description = dlerror(); -- cgit v1.2.1