当前位置: 技术问答>linux和unix
请问Linux下如何编译C程序啊???在线等
来源: 互联网 发布时间:2015-08-13
本文导语: 我想要最详细的答案,谢谢! | gcc -o desfilename srcfilename.c | gcc -o 输出文件名 源文件.c 这不是生成目标文件,而是直接生成可执行文件 要生成目标文件应加-c选项。 ...
我想要最详细的答案,谢谢!
|
gcc -o desfilename srcfilename.c
|
gcc -o 输出文件名 源文件.c
这不是生成目标文件,而是直接生成可执行文件
要生成目标文件应加-c选项。
这不是生成目标文件,而是直接生成可执行文件
要生成目标文件应加-c选项。
|
同楼上
输出文件可以用
./filename
来执行
输出文件可以用
./filename
来执行
|
man gcc
这样就可以得到gcc的详细信息了
gcc是linux的c/c++编译器
这样就可以得到gcc的详细信息了
gcc是linux的c/c++编译器
|
这里是man gcc的一部分信息,
自己看一下印象深一些
]# man gcc
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 remain-
der. 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 docu-
mented 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 single-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 documents only one of these two forms, whichever
one is not the default.
OPTIONS
Option Summary
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 documents only one of these two forms, whichever
one is not the default.
OPTIONS
Option Summary
Here is a summary of all the options, grouped by type. Explanations
are in the following sections.
Overall Options
-c -S -E -o file -pipe -pass-exit-codes -x language -v -###
--help --target-help --version
C Language Options
-ansi -std=standard -aux-info filename -fno-asm -fno-builtin
-fno-builtin-function -fhosted -ffreestanding -trigraphs
-no-integrated-cpp -traditional -traditional-cpp -fallow-sin-
gle-precision -fcond-mismatch -fsigned-bitfields -fsigned-char
-funsigned-bitfields -funsigned-char -fwritable-strings
C++ Language Options
-fno-access-control -fcheck-new -fconserve-space
-fno-const-strings -fdollars-in-identifiers -fno-elide-construc-
tors -fno-enforce-eh-specs -fexternal-templates -falt-exter-
nal-templates -ffor-scope -fno-for-scope -fno-gnu-keywords
-fno-implicit-templates -fno-implicit-inline-templates -fno-imple-
ment-inlines -fms-extensions -fno-nonansi-builtins -fno-opera-
tor-names -fno-optional-diags -fpermissive -frepo -fno-rtti
-fstats -ftemplate-depth-n -fuse-cxa-atexit -fvtable-gc
-fno-weak -nostdinc++ -fno-default-inline -Wabi -Wctor-dtor-pri-
vacy -Wnon-virtual-dtor -Wreorder -Weffc++ -Wno-deprecated
-Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual
自己看一下印象深一些
]# man gcc
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 remain-
der. 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 docu-
mented 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 single-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 documents only one of these two forms, whichever
one is not the default.
OPTIONS
Option Summary
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 documents only one of these two forms, whichever
one is not the default.
OPTIONS
Option Summary
Here is a summary of all the options, grouped by type. Explanations
are in the following sections.
Overall Options
-c -S -E -o file -pipe -pass-exit-codes -x language -v -###
--help --target-help --version
C Language Options
-ansi -std=standard -aux-info filename -fno-asm -fno-builtin
-fno-builtin-function -fhosted -ffreestanding -trigraphs
-no-integrated-cpp -traditional -traditional-cpp -fallow-sin-
gle-precision -fcond-mismatch -fsigned-bitfields -fsigned-char
-funsigned-bitfields -funsigned-char -fwritable-strings
C++ Language Options
-fno-access-control -fcheck-new -fconserve-space
-fno-const-strings -fdollars-in-identifiers -fno-elide-construc-
tors -fno-enforce-eh-specs -fexternal-templates -falt-exter-
nal-templates -ffor-scope -fno-for-scope -fno-gnu-keywords
-fno-implicit-templates -fno-implicit-inline-templates -fno-imple-
ment-inlines -fms-extensions -fno-nonansi-builtins -fno-opera-
tor-names -fno-optional-diags -fpermissive -frepo -fno-rtti
-fstats -ftemplate-depth-n -fuse-cxa-atexit -fvtable-gc
-fno-weak -nostdinc++ -fno-default-inline -Wabi -Wctor-dtor-pri-
vacy -Wnon-virtual-dtor -Wreorder -Weffc++ -Wno-deprecated
-Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual