G++ -I option for compiling program

守給你的承諾、 提交于 2019-12-10 17:06:41

问题


Here is a little problem that cannot be resolved by me such a Linux program newbie.

Now I have a main.cpp program which need to be compiled, there is a

#include "Down.h"

in the front of file.

Actually, this header file exist in the other directory, which locates at ../../../include directory. Besides, some other header files needed by Down.h also locate at this ../../../include directory.

Here is the problem, I compile main.cpp with command

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

However, it gives lots of error info which means it is not correct to be done like this.

Should I also change the include declaration into this one?

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

May you please leave me with some advice? Thanks.

Edit:

After using g++ -I ../../../include main.cpp, I get the following errors:

$ 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 

回答1:


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

See that leading slash after the -I? That's an absolute path.
Change it to a relative path (shown below) and it'll work OK.

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



回答2:


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

ought to work




回答3:


Try to use -v option:

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

And check that list of directories to search for include files contains your folder and there is no complains that this folder is absent. If there is this sort of complains correct the path that you give after -I



来源:https://stackoverflow.com/questions/1803467/g-i-option-for-compiling-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!