什么是g ++ -I选项(大写i)?

时间:2015-12-04 10:55:33

标签: g++ gnu

尝试执行this并偶然发现-I选项:$ g++ -o version version.cpp -I/usr/local/qt4/include/QtCore -I/usr/local/qt4/include -L/usr/local/qt4/lib -lQtCore

我无法找到有关它的任何信息

2 个答案:

答案 0 :(得分:0)

如果我的理解是正确的,问题是关于-i,而不是-L,我希望这会有所帮助:

-Idir将目录dir添加到搜索包含文件的目录列表中。

在此链接上 http://www.cs.virginia.edu/helpnet/Software_Development/compilers/g.html

g ++ - GNU项目C ++编译器(v2初步)

 g++ [option | filename] ...

功能

The C and C++ compilers are integrated. Both process input files through one or more of four stages: preprocessing, compilation, assembly, and linking.
C++ source files use one of the suffixes `.C', `.cc', or `.cxx'. 

选项 有许多命令行选项,包括控制优化,警告和代码生成细节的选项,这些选项对gcc和g ++都是通用的。有关所有选项的完整信息,请参阅gcc(1)。

选项必须分开:-dr' is quite different from - d -r'。

-c Compile or assemble the source files, but do not link. The compiler output is an object file corresponding to each source file.
-Dmacro Define macro macro with the string `1' as its definition.
-Dmacro=defn Define macro as defn
-E Stop after the preprocessing stage; do not run the compiler proper. The output is preprocessed source code, which is sent to the standard output.
- g Produce debugging information in the operating system's native format (for DBX or SDB or DWARF). GDB also can work with this debugging information. On most systems that use DBX format, `-g' enables use of extra debugging information that only GDB can use.
Unlike most other C compilers, GNU CC allows you to use ` -g' with `-O'. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops.
Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.
-Idir Append directory dir to the list of directories searched for include files.
-llibrary Use the library named library when linking. (C++ programs often require `-lg++' for successful linking.)
-O Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function.
Without `-O', the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code.
Without `-O', only variables declared register are allocated in registers. The resulting compiled code is a little worse than produced by PCC without `-O'.
With `-O', the compiler tries to reduce code size and execution time.
-o file Place output in file file. 

答案 1 :(得分:0)

如果您正在寻找-I的作用,

-I[/path/to/header-files]
Add search path to header files (.h) or (.hpp).

来自{{3}}

这几乎意味着您必须引用对外部库(在您的情况下为qt)所做的任何#include语句,以便g ++知道在哪里查找。