MongoDB的C驱动与我的计划 [英] Mongodb C driver with my program
本文介绍了MongoDB的C驱动与我的计划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不得不从分升的github.com MongoDB的-C驱动器,并编译它没有问题,但是,当我尝试编译我的C程序中,出现问题:
I had dl the Mongodb-c-driver from github.com, and compile it without problem, however, while I try to compile my C program, problem occurs:
testmongo.c:(.text+0x20): undefined reference to 'mongo_client'
testmongo.c:(.text+0x80): undefined reference to 'mongo_destroy'
我在链接的LDCONFIG MongoDB的图书馆,然而,这种情况不改变...
I have link the mongodb library in ldconfig, however, this situation don't change...
#include <stdio.h>
#include <mongo.h>
int main() {
mongo conn[1];
int status = mongo_client( conn, "127.0.0.1", 27017 );
if( status != MONGO_OK ) {
switch ( conn->err ) {
case MONGO_CONN_NO_SOCKET: printf( "no socket\n" ); return 1;
case MONGO_CONN_FAIL: printf( "connection failed\n" ); return 1;
case MONGO_CONN_NOT_MASTER: printf( "not master\n" ); return 1;
}
}
mongo_destroy( conn );
return 0;
}
谁能帮助?
非常感谢你!
Could anyone Help? Thank you very much !!!
推荐答案
我猜,直到更多的信息给我提出这是一个答案。在一种预感,你可能会丢失 -lmongoclient
从您的gcc命令。
I guess I should submit this as an answer until more information is given. On a hunch, you might be missing -lmongoclient
from your gcc command.
gcc -o myprog -lmongoclient source.c
这篇关于MongoDB的C驱动与我的计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文