gpt4 book ai didi

c - libmemcached 问题

转载 作者:太空宇宙 更新时间:2023-11-04 07:41:26 26 4
gpt4 key购买 nike

当我在我的 ubuntu 上运行 libmemcached 示例代码时,它给了我错误“对 `memcached_create' 的 undefined reference ”,任何人都可以帮忙吗?谢谢

#include <libmemcached/memcached.h>

int main(int argc, char **argv) {
//memcached_servers_parse (char *server_strings);
memcached_server_st *servers = NULL;
memcached_st *memc;
memcached_return rc;
char *key= "keystring";
char *value= "keyvalue";

memc= memcached_create(NULL);
servers= memcached_server_list_append(servers, "localhost", 11211, &rc); rc= memcached_server_push(memc, servers);

if (rc == MEMCACHED_SUCCESS)
fprintf(stderr,"Added server successfully\n"); else
fprintf(stderr,"Couldn't add server: %s\n",memcached_strerror(memc, rc));

rc= memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0);

if (rc == MEMCACHED_SUCCESS)
fprintf(stderr,"Key stored successfully\n"); else
fprintf(stderr,"Couldn't store key: %s\n",memcached_strerror(memc, rc));

return 0;

}

最佳答案

-lmemcached 传递给 GCC。这告诉它链接到 libmemcached.so 共享库。

关于c - libmemcached 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3744156/

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