这是演示代码,我用它来测试一切是否正常
#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;
}
}
printf( "connection done\n");
mongo_destroy( conn );
return 0;
}
这里是编译错误信息,不知道为什么,找不到mongo驱动?
# cc --std=c99 demo.c -o demo
/tmp/ccucuugp.o: In function `main':
demo.c:(.text+0x2e): undefined reference to `mongo_client'
demo.c:(.text+0xc2): undefined reference to `mongo_destroy'
collect2: ld returned 1 exit status
任何人都可以帮忙吗?