Linux下C++调用后端接口

适用场景:

C++调动后端接口,给后端发送请求时。

1. 安装相应库

sudo apt-get install curl
sudo apt-get install libcurl4-openssl-dev

2. 引入头文件

#include<curl/curl.h>

3. 使用curl相应的函数发送请求

出现的问题:

编译程序时,出现 'curl_easy_init' was not declared in this scope 问题时,说明虽然系统上有了curl的包,但是程序没有识别,要在编译时加上参数
-L/usr/lib/x86_64-linux-gnu -lcurl

(完)

原文地址:https://www.cnblogs.com/habit2021/p/15496608.html