c++terminalg++odb

Trying to use -I option with g++


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++?


Solution

  • 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.