Home > Backend Development > PHP Tutorial > Solution to libcurl.so.3 not found after libcurl upgrade_PHP tutorial

Solution to libcurl.so.3 not found after libcurl upgrade_PHP tutorial

WBOY
Release: 2016-07-13 10:42:58
Original
2420 people have browsed it

This article today will introduce to you a solution to the problem that libcurl.so.3 cannot be found after libcurl upgrade. I hope it will be helpful to all my friends.

The system is installed with version libcurl 7.19, and the compiled dynamic library is libcurl.so.4

My program is compiled under the libcurl 7.15 version, and the libcurl.so.3 version is used. Just make a 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 或者 cd /usr/lib64
ln -s libcurl.so.4 libcurl.so.3

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


The main function of libcurl is to use different protocols to connect and communicate with different servers ~ that is, sockPHP is quite encapsulated and supports libcurl (allowing you to use different protocols to connect and communicate with different servers). , 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 upload, proxies, cookies, and user authentication.

Give me a simple code example:
Description:
1. The key is to set the option in the curl_easy_setopt function. You can set many options such as ftp, http, get, post, etc. Please set according to the specific usage.

2. The retrieved data needs to be judged, such as http download files. If the file does not exist, it needs to be processed. Because the writer can fill buf with 404 not found and other web page content, and cannot regard this content as file content, so it needs to judge the code returned by http web to make a judgment.

3. I have a problem, that is, I want to get the specific name of the filename on the server. The verbose debugging has returned, but when I tried getinfo, I tried many options, but I did not find this option to store the real server file name. If If you know anything, please 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 == 200 )
    {
        double length = 0;
        code = curl_easy_getinfo(curl, CURLINFO_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;
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/633209.htmlTechArticle本文章今天来给大家介绍一个libcurl升级后找不到libcurl.so.3解决之法,希望对各位朋友有帮助呀。 系统装的是libcurl 7.19的版本,编译的动态库...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template