Trying to use -I option with g++

2.8k views Asked by At

I am trying to compile a source file driver.cxx and among its include files is a library called

The path to this file is /home/terry/Downloads/libodb-2-4-0/odb/sqlite/database.hxx

to compile it I enter the following:

g++ -c driver.cxx -I/home/terry/Downloads/libodb-2.4.0/odb

And get the message

driver.cxx:10:35: fatal error: odb/sqlite/database.hxx: No such file or directory #include ^ compilation terminated.

How do I mention the path when using the -I flag for g++?

4

There are 4 answers

0
Zilicon On BEST ANSWER

According to the error you pasted it looks like your include command is:

#include "odb/sqlite/database.hxx"

If so, your -I option should be without odb dir (since it's already mentioned in the include):

-I/home/terry/Downloads/libodb-2.4.0/

All in all the -I concatenated with the include should be the exact path.


Meaning if you decide to include with:

#include "database.hxx"

Your -I option should be:

-I/home/terry/Downloads/libodb-2.4.0/odb/sqlite

Again, -I + include = exact path.

0
marom On

Since the error message mentions 'odb' part of the path I would remove it from -I flag

0
bhavesh On

Let's say you want to use database.hxx in your .cpp file. Then in your .cpp file you should write:

#include "database.hxx"

and for compiling you should mention the path where the .h is present. So in your case it would be.

-I /home/terry/Downloads/libodb-2-4-0/odb/sqlite/

0
psliwa On

I can see that your error mentions you use #include <odb/sqlite/database.hxx>. Try to change it to #include <database.hxx>.