G ++ -I option for compiling a program

Here is a small problem that cannot be solved by me such a newbie Linux program.

Now I have a program main.cpp that needs to be compiled, there is

#include "Down.h" 

at the beginning of the file.

Actually, this header file exists in another directory, which is located in ../../../include directory. In addition, some other header files needed by Down.h are also located in this directory .. /../../include.

Here is the problem, I am compiling main.cpp with the command

 g++ -I /../../../include main.cpp 

However, it does provide a lot of error information, which means it is not right to do this.

Or should I also change the include declaration to this?

 #include "../../../include/DownConvert.h" 

So can you give me some advice? Thanks.

after using g ++ -I ../../../ include main.cpp, I get the following errors, maybe you can take a look at them, thanks.

 $ g++ -I ../../../include main.cpp In file included from ../../../include/DownConvert.h:98, from main.cpp:92: ../../../include/ResizeParameters.h:4:22: error: TypeDefs.h: No such file or directory In file included from /usr/include/c++/4.4/bits/stl_algo.h:61, from /usr/include/c++/4.4/algorithm:62, from ../../../include/H2 
+4
source share
3 answers
 g++ -I /../../../include main.cpp 

Look at this main feature after -I, which is the absolute path. Change it to relative path (shown below), it will work fine

 g++ -I ../../../include main.cpp 
+6
source

g ++ -I ../../../ include main.cpp

must work

0
source

Try using the -v option:

 g++ -v -I ../../../include main.cpp 

And check that the list of directories to search for included files contains your folder, and there are no messages indicating that this folder is missing. If there are any complaints, correct the path you give after -I

0
source

All Articles