search
HomeBackend DevelopmentPHP TutorialSolution to libcurl.so.3 not found after libcurl upgrade_PHP tutorial

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的版本,编译的动态库...
Statement
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
Optimize PHP Code: Reducing Memory Usage & Execution TimeOptimize PHP Code: Reducing Memory Usage & Execution TimeMay 10, 2025 am 12:04 AM

TooptimizePHPcodeforreducedmemoryusageandexecutiontime,followthesesteps:1)Usereferencesinsteadofcopyinglargedatastructurestoreducememoryconsumption.2)LeveragePHP'sbuilt-infunctionslikearray_mapforfasterexecution.3)Implementcachingmechanisms,suchasAPC

PHP Email: Step-by-Step Sending GuidePHP Email: Step-by-Step Sending GuideMay 09, 2025 am 12:14 AM

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

How to Send Email via PHP: Examples & CodeHow to Send Email via PHP: Examples & CodeMay 09, 2025 am 12:13 AM

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

Advanced PHP Email: Custom Headers & FeaturesAdvanced PHP Email: Custom Headers & FeaturesMay 09, 2025 am 12:13 AM

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Guide to Sending Emails with PHP & SMTPGuide to Sending Emails with PHP & SMTPMay 09, 2025 am 12:06 AM

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.