gpt4 book ai didi

c++ - curl_easy_getinfo undefined symbol 错误

转载 作者:行者123 更新时间:2023-11-28 06:07:26 25 4
gpt4 key购买 nike

我使用的是 asterisk 版本 13.5.0。在 utils 目录中,我创建了一个名为 curl_util 的新模块,其源代码如下:

#include "asterisk/curl_utils.h"
HttpResponse * httpResponseNew()
{
HttpResponse * response = calloc(1, sizeof(HttpResponse));

return response;
error:
return NULL;
}

HttpResponse * httpRequestPost(char *url, char *post_body, size_t size)
{
struct MemoryStruct chunk;
CURL *curl = curl_easy_init();

chunk.memory = malloc(1);
chunk.size = 0;

HttpResponse *response = httpResponseNew();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0);
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_body);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, size);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HttpResponseMemoryWriter);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);

response->res = curl_easy_perform(curl);

if (response->res != CURLE_OK)
{
response->OK = 0;
}
else
{
response->OK = 1;
response->size = chunk.size;
response->body = chunk.memory;
}

curl_easy_cleanup(curl);

return response;

error:
free(chunk.memory);
if (curl) curl_easy_cleanup(curl);
return response;
}

在chan_sip.c中,我调用了上面提到的httpRequestPost函数。执行make和make install就OK了。但是,当启动 dahdi 和 asterisk 时,出现以下错误:

加载模块 chan_sip.so 时出错: undefined symbol :httpRequestPost

loader.c: 无法加载模块 chan_sip.so。

能否请您提供提示或建议来修复此错误?提前谢谢你。

最佳答案

不需要编辑 makefile。您只需要使用 ASTLDFLAGS 编译器选项,例如:

./configure
make ASTLDFLAGS="-lcurl"
make install
make samples
make config

关于c++ - curl_easy_getinfo undefined symbol 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32113027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com