Question

I get the mongo-c-driver from official website, as follows:

$git https://github.com/mongodb/mongo-c-driver.git
$cd mongo-c-driver
$./autogen.sh
$ make
$ sudo make install
Deal.c:2:19: fatal error: mongo.h: No such file or directory

However,when I run my C file named "Deal.c" like this:

gcc -o Deal Deal.c -l /usr/local/include -L /usr/local/lib -lmongoc
Error:#include "mongo.h"
                     ^ compilation terminated.

My system version: is Ubuntu 13.10

Was it helpful?

Solution

It appears that you are missing the path to the headers as well as the locations of the libraries. One option would be to install to the same prefix that your platform uses, such as:

./configure --prefix=/usr --libdir=/usr/lib64

If that is not an option, then you can update your Makefile to include the proper library and include path as such:

gcc Deal.c -L/usr/local/lib -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -lmongoc-1.0 -lbson-1.0

This will typically be done automatically for you by using pkg-config on Unix'like systems as such:

gcc Deal.c $(pkg-config --cflags --libs libmongoc-1.0)

However, if you install into a non-standard path such as /usr/local, then you will need to let pkg-config know where to find the libmongoc-1.0.pc file, such as:

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gcc Deal.c $(pkg-config --cflags --libs libmongoc-1.0)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top