免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3441 | 回复: 10
打印 上一主题 下一主题

[C] Linux下,gcc 编译c代码的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-09-07 08:40 |只看该作者 |倒序浏览
谁来解释一下这个命令?
[oracle@Tux10M simpapp]$ gcc fetch.c -I /u01/app/oracle/product/10.2.0/client_1/precomp/public/ -L /u01/app/oracle/product/10.2.0/client_1/lib/ -lclntsh

I是什么意思?
L是什么意思?

man过gcc,看不懂。

论坛徽章:
0
2 [报告]
发表于 2010-09-07 08:40 |只看该作者
GCC(1)                                                         GNU                                                         GCC(1)

NAME
       gcc - GNU project C and C++ compiler

SYNOPSIS
       gcc [-c|-S|-E] [-std=standard]
           [-g] [-pg] [-Olevel]
           [-Wwarn...] [-pedantic]
           [-Idir...] [-Ldir...]
           [-Dmacro[=defn]...] [-Umacro]
           [-foption...] [-mmachine-option...]
           [-o outfile] infile...

       Only the most useful options are listed here; see below for the remainder.  g++ accepts mostly the same options as gcc.

DESCRIPTION
       When you invoke GCC, it normally does preprocessing, compilation, assembly and linking.  The ''overall options'' allow you
       to stop this process at an intermediate stage.  For example, the -c option says not to run the linker.  Then the output
       consists of object files output by the assembler.

       Other options are passed on to one stage of processing.  Some options control the preprocessor and others the compiler
       itself.  Yet other options control the assembler and linker; most of these are not documented here, since you rarely need
       to use any of them.

       Most of the command line options that you can use with GCC are useful for C programs; when an option is only useful with
       another language (usually C++), the explanation says so explicitly.  If the description for a particular option does not
       mention a source language, you can use that option with all supported languages.

       The gcc program accepts options and file names as operands.  Many options have multi-letter names; therefore multiple sin-
       gle-letter options may not be grouped: -dr is very different from -d -r.

       You can mix options and other arguments.  For the most part, the order you use doesn't matter.  Order does matter when you
       use several options of the same kind; for example, if you specify -L more than once, the directories are searched in the
       order specified.

       Many options have long names starting with -f or with -W---for example, -fforce-mem, -fstrength-reduce, -Wformat and so
       on.  Most of these have both positive and negative forms; the negative form of -ffoo would be -fno-foo.  This manual docu-
       ments only one of these two forms, whichever one is not the default.

论坛徽章:
324
射手座
日期:2013-08-23 12:04:38射手座
日期:2013-08-23 16:18:12未羊
日期:2013-08-30 14:33:15水瓶座
日期:2013-09-02 16:44:31摩羯座
日期:2013-09-25 09:33:52双子座
日期:2013-09-26 12:21:10金牛座
日期:2013-10-14 09:08:49申猴
日期:2013-10-16 13:09:43子鼠
日期:2013-10-17 23:23:19射手座
日期:2013-10-18 13:00:27金牛座
日期:2013-10-18 15:47:57午马
日期:2013-10-18 21:43:38
3 [报告]
发表于 2010-09-07 08:48 |只看该作者
-I 头文件的目录
-L lib的目录

论坛徽章:
0
4 [报告]
发表于 2010-09-07 08:52 |只看该作者
  1.        -I dir
  2.            Add the directory dir to the list of directories to be searched for header files.  Directories named by -I
  3.            are searched before the standard system include directories.  If the directory dir is a standard system
  4.            include directory, the option is ignored to ensure that the default search order for system directories and
  5.            the special treatment of system headers are not defeated .  If dir begins with "=", then the "=" will be
  6.            replaced by the sysroot prefix; see --sysroot and -isysroot.
复制代码

论坛徽章:
0
5 [报告]
发表于 2010-09-07 13:11 |只看该作者
I添加头文件,L添加库

论坛徽章:
0
6 [报告]
发表于 2010-09-07 20:26 |只看该作者
I 头文件路径
L 库文件路径

论坛徽章:
0
7 [报告]
发表于 2010-09-08 10:54 |只看该作者
恩 -I 是包含的头文件的路径名 一般头文件是在 /usr/local/include /usr/include 比如你要用oracle的一些头文件,-I 后面是你的头文件的路径. -L 是动态链接库的路径 一般动态链接库是在 /usr/lib /usr/local/lib下 但是你要用的库可能在你安装oracle的lib下 所以你需要指定一下路径. ldd  这个命令可以看到你生成后的可执行文件是否都有依赖库,具体用法可以查查

论坛徽章:
0
8 [报告]
发表于 2010-09-08 14:42 |只看该作者
果然,我没走错地方,感谢兄弟们

论坛徽章:
0
9 [报告]
发表于 2010-09-08 14:43 |只看该作者
本帖最后由 cups_book 于 2010-09-08 14:47 编辑

那以上的兄弟们,谁有办法把以下的命令的两个I去掉?
[oracle@Tux10M simpapp]$ gcc fetch.c -I /u01/app/oracle/product/10.2.0/client_1/precomp/public/ -I /home/oracle/tux10/include -L /u01/app/oracle/product/10.2.0/client_1/lib/ -lclntsh
[oracle@Tux10M simpapp]$

也不是去掉,就是加到某个配置文件中去,从而不用每次都敲这么长的命令,--我不要用写成脚本,每次执行脚本的方法。

论坛徽章:
324
射手座
日期:2013-08-23 12:04:38射手座
日期:2013-08-23 16:18:12未羊
日期:2013-08-30 14:33:15水瓶座
日期:2013-09-02 16:44:31摩羯座
日期:2013-09-25 09:33:52双子座
日期:2013-09-26 12:21:10金牛座
日期:2013-10-14 09:08:49申猴
日期:2013-10-16 13:09:43子鼠
日期:2013-10-17 23:23:19射手座
日期:2013-10-18 13:00:27金牛座
日期:2013-10-18 15:47:57午马
日期:2013-10-18 21:43:38
10 [报告]
发表于 2010-09-08 14:58 |只看该作者
那以上的兄弟们,谁有办法把以下的命令的两个I去掉?
[oracle@Tux10M simpapp]$ gcc fetch.c -I /u01/app/ ...
cups_book 发表于 2010-09-08 14:43



    为啥不用make?
要不源代码中include指明全路径好了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP