Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongo.h: No such file or directory

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

like image 770
user2270421 Avatar asked Dec 12 '25 11:12

user2270421


1 Answers

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)
like image 99
user2562047 Avatar answered Dec 15 '25 12:12

user2562047



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!