一起喝酒和libcurl
swig and libcurl together
我正在学习制作PHP扩展,我看到了一篇关于swig的博客文章。我试着用libcurl创建一个代码,但是我无法编译它。
%{
#include <stdio.h>
#include <curl/curl.h>
bool wsper(char* url, char* postdata){
CURL* curl = curl_easy_init();
CURLcode res;
if(curl){
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postdata);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
res = curl_easy_perform(curl);
if(res == CURLE_OK){
curl_easy_cleanup(curl);
return true;
}else{
return false;
}
}else{
return false;
}
}
%}
%module wsper
extern bool wsper(char* url, char* postdata);
运行以下命令后,我没有遇到任何错误
swig -php file.c
g++ `php-config --includes` -fpic -lcurl -lcurlpp -c
wsper_wrap.c g++ -shared file_wrap.o -o file.so
但是当我尝试运行php文件时,我有一个错误说:
未定义符号:curl_easy_perform在未知行0
您的链接扩展错误。在使用-c调用g++的地方使用-lcurl -lcurlpp。
当您使用-shared和-o file.so调用它时,您需要使用-fpic -lcurl -lcurlpp。
。最后的链接应该是:
g++ -shared file_wrap.o -o file.so -lcurl -lcurlpp
相关文章:
- 发送一个带有libcurl C++问题的帖子请求:s
- 使用libcurl提交批量url的正确BING Api POST url是什么
- 在 libcurl 连接池中预创建连接
- libcurl 和 DNS ttl 中的内部连接管理
- 如何在 cmake 库中包含 libcurl
- 如何应用 libcurl 的持久连接选项
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 组合字符串不适用于 libCurl,C++
- Poloniex API "Invalid command" c++ libcurl
- libcurl :显示正在运行的上传和下载速率
- c++ libCurl :如何使用libCurl接受过期的证书
- libcurl :C++处理多个异步请求
- 现代C++的libcurl和JSON问题
- 使用 Libcurl 库进行文件下载
- 如何在C++生成器中使用libcurl
- Libcurl c++ "undefined reference to" (Windows/MinGW/g++)
- 如何使用 libcurl 在本地 IP 上获取 HTML?
- 如何将带有 -F 选项的 curl 命令转换为 libcurl
- 如何使用 libCurl 将访问令牌发送到服务器 API
- 一起喝酒和libcurl