Libcurl cannot find libcurl.so.3 solution after upgrade _php tutorial

Source: Internet
Author: User
This article today to introduce you to a Libcurl upgrade can not find libcurl.so.3 solution to the law, I hope to help you friends.

The system is Libcurl version 7.19, the compiled dynamic library is libcurl.so.4

Its own program is compiled in the version of Libcurl 7.15, with the version of Libcurl.so.3, to do the following soft link:
Depending on whether you are using a 32-bit system or a 64-bit system, do the following:

The code is as follows Copy Code

Cd/usr/lib or cd/usr/lib64
Ln-s libcurl.so.4 libcurl.so.3


Libcurl main function is to use different protocols to connect and communicate with different servers-that is, quite encapsulated sockphp support Libcurl (allowing you to connect and communicate different servers with different protocols). , Libcurl currently supports HTTP, HTTPS, FTP, Gopher, Telnet, dict, file, and LDAP protocols. Libcurl also supports HTTPS certificate authorization, HTTP POST, HTTP PUT, FTP upload (of course you can also use PHP's FTP extension), HTTP basic form uploads, proxies, cookies, and user authentication.

Give me a simple code example:
Description
1. Key in the CURL_EASY_SETOPT function set option, you can set a number of options such as Ftp,http,get,post, depending on the use of the settings.

2. The retrieved data needs to be judged, such as the HTTP download file, if the file does not exist, it needs to be processed. Because writer is able to fill buf 404 Not Found and other Web content, this content can not be used as a file content, so you need to judge the HTTP Web return code, to judge.

3. I have a problem, I want to get the name of filename on the server, verbose debugging has returned, but I getinfo in the time, tried a lot of options, but did not find the real server file name option, if you have to know the trouble to tell me, thank you!

The code is as follows Copy Code


#include "curl/curl.h"
#pragma comment (lib, "Libcurl.lib")

Long writer (void *data, int size, int nmemb, string &content);
BOOL Curlinit (CURL *&curl, const char* url,string &content);
BOOL Geturldatabycurl (const char* URL, string &content);

void Main ()
{
Char *url = "http://www.bKjia.c0m";
string content;
if (Geturldatabycurl (url,content))
{
printf ("%SN", content);

}
GetChar ();
}

BOOL Curlinit (CURL *&curl, const char* url,string &content)
{
Curlcode Code;
String error;
Curl = Curl_easy_init ();
if (curl = = NULL)
{
printf ("Failed to create CURL connectionn");
return false;
}
Code = curl_easy_setopt (Curl, Curlopt_errorbuffer, error);
if (Code! = CURLE_OK)
{
printf ("Failed to set error buffer [%d]n", code);
return false;
}
Curl_easy_setopt (Curl, Curlopt_verbose, 1L);
Code = curl_easy_setopt (Curl, Curlopt_url, URL);
if (Code! = CURLE_OK)
{
printf ("Failed to set URL [%s]n", error);
return false;
}
Code = curl_easy_setopt (Curl, curlopt_followlocation, 1);
if (Code! = CURLE_OK)
{
printf ("Failed to set redirect option [%s]n", error);
return false;
}
Code = curl_easy_setopt (Curl, curlopt_writefunction, writer);
if (Code! = CURLE_OK)
{
printf ("Failed to set writer [%s]n", error);
return false;
}
Code = curl_easy_setopt (Curl, Curlopt_writedata, &content);
if (Code! = CURLE_OK)
{
printf ("Failed to set write data [%s]n", error);
return false;
}
return true;
}

Long writer (void *data, int size, int nmemb, string &content)
{
Long sizes = size * NMEMB;
String temp (data,sizes);
Content + = temp;
return sizes;
}

BOOL Geturldatabycurl (const char* URL, String &content)
{
CURL *curl = NULL;
Curlcode Code;
String error;

Code = curl_global_init (Curl_global_default);
if (Code! = CURLE_OK)
{
printf ("Failed to global init default [%d]n", code);
return false;
}

if (! Curlinit (curl,url,content))
{
printf ("Failed to global init default [%d]n");
return pm_false;
}
Code = curl_easy_perform (curl);
if (Code! = CURLE_OK)
{
printf ("Failed to get '%s ' [%s]n", URL, error);
return false;
}
Long retcode = 0;
Code = curl_easy_getinfo (Curl, Curlinfo_response_code, &retcode);
if (code = = CURLE_OK) && Retcode = =)
{
Double length = 0;
Code = curl_easy_getinfo (Curl, C Urlinfo_content_length_download, &length);
printf ("%d", retcode);
File * file = fopen ("1.gif", "WB");
Fseek (File,0,seek_set);
Fwrite (Content.c_str (), 1,length,file);
fclose (file);

struct Curl_slist *list;
Code = curl_easy_getinfo (curl,curlinfo_cookielist,&list);
Curl_slist_free_all (list);

return true;
}
Else
{
DEBUG1 ("%s n", Getstatuscode (Retcode));
return false;
}
Curl_easy_cleanup (curl);
return false;
}

http://www.bkjia.com/PHPjc/633209.html www.bkjia.com true http://www.bkjia.com/PHPjc/633209.html techarticle This article today to introduce you to a Libcurl upgrade can not find libcurl.so.3 solution to the law, I hope to help you friends. The system is loaded with the Libcurl 7.19 version, the compiled dynamic library ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.