G ++ -I编译程序选项 [英] G++ -I option for compiling program

查看:144
本文介绍了G ++ -I编译程序选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个小问题,不能由我解决这样的Linux程序新手。

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

现在我有一个main.cpp程序,需要编译,是

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

#include "Down.h"

实际上,这个头文件存在于另一个目录中,它位于
../../../ include
目录。此外,Down.h所需的一些其他头文件也位于这个../../../include目录。

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.

这里是问题,我编译main .cpp with command

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.

还是应该将include声明改成这个呢?

Or should I also change the include declaration into this one?

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

所以,你能给我一些建议?感谢。

So, can you leave me some advices? Thanks.

使用g ++ -I ../../../后,包括main.cpp,我得到以下错误,也许你可以看看他们, 谢谢。

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 


推荐答案

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

在-I后面看到前导斜杠,这是一个绝对路径。将其更改为相对路径(如下所示),它会正常工作

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

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

这篇关于G ++ -I编译程序选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆