mongodb - mongo c driver install issue : test.c error: mongoc.h: No such file or directory -


== installed: mongo-c-driver-1.1.0 /usr/src/mongo-c-driver-1.1.0/src/mongoc

issue : header file in same direcroty still not getting .

=====

mongo c driver install issue : test.c error: mongoc.h: no such file or directory root@webrtc mongoc]# vim  test.c [root@webrtc mongoc]# gcc cflags=-std=c99 test.c 192.168.0.181 27017 -o test.o gcc: cflags=-std=c99: no such file or directory gcc: 192.168.0.181: no such file or directory gcc: 27017: no such file or directory test.c:18:20: error: mongoc.h: no such file or directory test.c: in function ‘main’: test.c:26: error: ‘mongoc_database_t’ undeclared (first use in function) test.c:26: error: (each undeclared identifier reported once test.c:26: error: each function appears in.) test.c:26: error: ‘database’ undeclared (first use in function) test.c:27: error: ‘mongoc_cursor_t’ undeclared (first use in function) test.c:27: error: ‘cursor’ undeclared (first use in function) 

code :

http://code-trick.com/mongodb-c-driver-examples/

https://github.com/mongodb/mongo-c-driver/releases

#include <mongoc.h> #include <stdio.h> int main (int   argc,       char *argv[])     port = (argc == 3) ? atoi(argv[2]) : 27017;     if (strncmp (argv[1], "mongodb://", 10) == 0) {       host_and_port = bson_strdup (argv [1]);    } else {       host_and_port = bson_strdup_printf("mongodb://%s:%hu", argv[1], port);    }     client = mongoc_client_new(host_and_port);     if (!client) {       fprintf(stderr, "invalid hostname or port: %s\n", host_and_port);       return 2;    }    bson_init(&ping);    bson_append_int32(&ping, "ping", 4, 1);    database = mongoc_client_get_database(client, "test");    cursor = mongoc_database_command(database, 0, 0, 1, 0, &ping, null, null);    if (mongoc_cursor_next(cursor, &reply)) {       str = bson_as_json(reply, null);       fprintf(stdout, "%s\n", str);       bson_free(str);    } else if (mongoc_cursor_error(cursor, &error)) {       fprintf(stderr, "ping failure: %s\n", error.message);       return 3;    }     mongoc_cursor_destroy(cursor);    bson_destroy(&ping);    mongoc_client_destroy(client);    bson_free(host_and_port);     return 0; } 

=====

gcc -o menu menu.c $(pkg-config --cflags --libs libmongoc-1.0) solved


Comments