6

So basically I have some really simple code that includes <BigIntegerLibrary.hh> which resides in /Users/wen/Projects/include/bigint. I was compiling with this:

g++ main.cpp -o Main -I/Users/wen/Projects/include/bigint

but it reported a fatal error that it could not find the file. Am I doing it right? Thanks!

main.cpp:4:10: fatal error: 'BigIntegerLibrary.hh' file not found

ihsoy ih
  • 1,008
  • 2
  • 10
  • 20

2 Answers2

6

Try

#include "BigIntegerLibrary.hh"

If you specify the #included file with angle brackets (#include <includeFile.h>) the compiler will try to find it in a predefined location whereas if you use #include "includeFile" the compiler first tries the paths you specified with the -I compiler option.

The -I compiler option cannot be used to specify where the <...> files are.

René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293
  • Are you sure you have the case of the letters in the path right? Did you double check with `ls /Users/wen/Projects/include/bigint/BigIntegerLibrary.hh`? – René Nyffenegger Dec 18 '12 at 17:32
  • Yup, double checked. When I did a `cat` on the path it showed the contents. – ihsoy ih Dec 18 '12 at 17:35
  • 1
    -I can change where <...> files are, it modifies the search path. Evidence: the manual, and that it works on my system. – bstamour Dec 18 '12 at 23:51
0

If the path is correct g++ should see the files.

If you use absolute path in include directive, you should change quotation:

#include "/Users/wen/Projects/include/bigint/BigIntegerLibrary.hh"
Dims
  • 47,675
  • 117
  • 331
  • 600