Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find mongoc.h

I can't find mongoc.h after installing Mongodb and C driver on Ubuntu 16.04.

sudo apt-get install mongodb
sudo apt-get install libmongoc-1.0-0
sudo apt-get install libbson-1.0

This is the error I get:

gcc -o mtest mtest.c -I/usr/local/include/libbson-1.0 -I/usr/local/include/libmongoc-1.0 -lmongoc-1.0 -lbson-1.0
mtest.c:1:20: fatal error: mongoc.h: No such file or directory
compilation terminated.

I checked the disk and can not find the file. Tips appreciated.

like image 320
RR1 Avatar asked Feb 25 '26 23:02

RR1


1 Answers

If you have installed via apt-get, then the packages almost certainly don't install to /usr/local, but to plain old /usr. What happens if you run

gcc -o mtest mtest.c -I/usr/include/libbson-1.0 -I/usr/include/libmongoc-1.0 -lmongoc-1.0 -lbson-1.0

P.S. The right way to pick up these paths is by using pkg-config instead of hard coding them, please see http://mongoc.org/libmongoc/current/tutorial.html#pkg-config

like image 90
acm Avatar answered Feb 27 '26 17:02

acm