linux查看编译参数
‘壹’ 在linux里,c程序的编辑、编译、调试的详细步骤是什么
(1)用工具写好C程序...比如vi
(2)打开终端,进入你存放C语言代码的路径 例如: cd /opt/
(3)gcc a.c -o abc 意思是:把你的a.c编译成abc可执行文件
(4)在当前目录终端下 运行生成的abc,例如: ./abc 前面的.不要掉了
后面可以用gdb进行调试,你可以自己去学习...这是最基本的!!
‘贰’ 求高手解答:linux系统编译问题
configure是每个源码包里自带的配置脚本,它会自动检查你的系统是否满足编译这个软件所需要的条件(比如,编译器是否安装,用到的头文件是否有,等等),并进行一些相关配置。
一般来说 ./configure后面带的参数主要是用来设置编译和安装这个软件时的一些相关参数,如果你不在 ./configure后面提供,那么编译、安装的时候就使用软件默认的设置。
最常见的参数就是 --prefix,指定安装软件的目录 (如果不指定,应该是默认为 /usr/local)。另外还有一些比方设置库路径,文档安装路径等参数 (这些参数一般各个软件都支持),还有一些是软件特有的配置参数,比如启用或者禁用某个特殊的功能等。具体每个软件的configure脚本支持哪些参数,可以用
./configure --help 的方法来查看。
第二个问题,./configure出错,一般来说就是你的系统不满足这个软件安装的要求,导致configure脚本检测出无法正确配置,如我上面说的,比方你没安装编译器或者编译器版本有问题,或者是缺少某个头文件,或者是缺少某些库等等,具体是什么问题,要看 ./configure 出错的提示了。
‘叁’ 如何查看程序被哪个版本编译器编译的linux-gcc
那是不可能的,除非你加入了调试信息,也就是编译的时候加入了-g参数,然后用gdb调试就可以显示。最大程度上查看一个elf文件信息。
{
readelf -Wa a.out | head
readelf -wi a.out
readelf -p .comment a.out
objmp -s --section .comment audioplayer
}
如下:
[root@localhost rootfs]# readelf -Wa bin/gzip
复制代码
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0xa080
Start of program headers: 52 (bytes into file)
Start of section headers: 1975444 (bytes into file)
Flags: 0x5000002, has entry point, Version5 EABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 6
Size of section headers: 40 (bytes)
Number of section headers: 25
Section header string table index: 24
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .note.ABI-tag NOTE 000080f4 0000f4 000020 00 A 0 0 4
[ 2] .init PROGBITS 00008114 000114 00000c 00 AX 0 0 4
[ 3] .text PROGBITS 00008120 000120 17fcfc 00 AX 0 0 16
[ 4] __libc_freeres_fn PROGBITS 00187e1c 17fe1c 000f20 00 AX 0 0 4
[ 5] __libc_thread_fre PROGBITS 00188d3c 180d3c 0000e4 00 AX 0 0 4
[ 6] .fini PROGBITS 00188e20 180e20 000008 00 AX 0 0 4
[ 7] .rodata PROGBITS 00188e28 180e28 058147 00 A 0 0 8
[ 8] __libc_subfreeres PROGBITS 001e0f70 1d8f70 00005c 00 A 0 0 4
[ 9] __libc_atexit PROGBITS 001e0fcc 1d8fcc 000004 00 A 0 0 4
[10] __libc_thread_sub PROGBITS 001e0fd0 1d8fd0 000008 00 A 0 0 4
[11] .ARM.extab PROGBITS 001e0fd8 1d8fd8 001b04 00 A 0 0 4
[12] .ARM.exidx ARM_EXIDX 001e2adc 1daadc 006ea8 00 AL 3 0 4
[13] .tdata PROGBITS 001f1984 1e1984 000018 00 WAT 0 0 4
[14] .tbss NOBITS 001f199c 1e199c 000034 00 WAT 0 0 4
[15] .init_array INIT_ARRAY 001f199c 1e199c 000004 00 WA 0 0 4
[16] .fini_array FINI_ARRAY 001f19a0 1e19a0 000008 00 WA 0 0 4
[17] .jcr PROGBITS 001f19a8 1e19a8 000004 00 WA 0 0 4
[18] .data.rel.ro PROGBITS 001f19ac 1e19ac 00002c 00 WA 0 0 4
[19] .got PROGBITS 001f19d8 1e19d8 00007c 04 WA 0 0 4
[20] .data PROGBITS 001f1a58 1e1a58 0008f7 00 WA 0 0 8
[21] .bss NOBITS 001f2350 1e234f 004828 00 WA 0 0 8
[22] __libc_freeres_pt NOBITS 001f6b78 1e234f 00003c 00 WA 0 0 4
[23] .ARM.attributes ARM_ATTRIBUTES 00000000 1e234f 00002b 00 0 0 1
[24] .shstrtab STRTAB 00000000 1e237a 000118 00 0 0 1
Section to Segment mapping:
Segment Sections...
00 .ARM.exidx
01 .note.ABI-tag .init .text __libc_freeres_fn __libc_thread_freeres_fn .fini .rodata __libc_subfreeres __libc_atexit __libc_thread_subfreeres .ARM.extab .ARM.exidx
02 .tdata .init_array .fini_array .jcr .data.rel.ro .got .data .bss __libc_freeres_ptrs
03 .note.ABI-tag
04 .tdata .tbss
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "5TE"
Tag_CPU_arch: v5TE
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align8_needed: Yes
Tag_ABI_align8_preserved: Yes, except leaf SP
Tag_ABI_enum_size: int
Tag_unknown_44: 1 (0x1)
复制代码
How to retrieve the GCC version used to compile a given ELF executable? http://stackoverflow.com/questions/2387040/how-to-retrieve-the-gcc-version-used-to-compile-a-given-elf-executable
QUES: I'd like to retrieve the GCC version used to compile a given executable. I tried readelf but didn't get the information. Any thoughts?
ANS: To complete what others have said: it's not stored in the object (or exe) file, unless you compile with debugging information! (option -g). If you compile with debug info, you can get it back with readelf:
复制代码
[root@localhost test]# gcc a.c
[root@localhost test]# readelf -wi a.out
[root@localhost test]# gcc a.c -g
[root@localhost test]# readelf -wi a.out
The section .debug_info contains:
Compilation Unit @ offset 0x0:
Length: 135
Version: 2
Abbrev Offset: 0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_stmt_list : 0
DW_AT_high_pc : 0x400453
DW_AT_low_pc : 0x400448
DW_AT_procer : GNU C 4.1.2 20080704 (Red Hat 4.1.2-55)
DW_AT_language : 1 (ANSI C)
DW_AT_name : a.c
DW_AT_comp_dir : /work/farsight/test
<1><61>: Abbrev Number: 2 (DW_TAG_subprogram)
DW_AT_external : 1
DW_AT_name : main
DW_AT_decl_file : 1
DW_AT_decl_line : 4
DW_AT_prototyped : 1
DW_AT_type : <83>
DW_AT_low_pc : 0x400448
DW_AT_high_pc : 0x400453
DW_AT_frame_base : 0 (location list)
<1><83>: Abbrev Number: 3 (DW_TAG_base_type)
DW_AT_name : int
DW_AT_byte_size : 4
DW_AT_encoding : 5 (signed)
复制代码
ANS2:
‘肆’ 拿到已经打包好的rpm包后,怎么查看rpm包的编译参数
rpm -qa my.rpm。另外在不知道的情况下可以使用“man XXX ”(XXX 为命令,如:man rpm)这一命令,里面足够的提示的,学Linux愉快!希望能办法到你。
‘伍’ linux下eclipse的编译参数
在main.c头部加上include "/home/ke/funciton.c"
‘陆’ linux怎么查看php安装编译参数
1、Linux下,默认是在/usr/local/bin/,假如你设置--prefix=/usr/local/php那么就在/usr/local/php/bin/ 2、sbin道理相同。sbin的意思就是server bin 3、EPREFIX没用过 4、如果要用2套版本,用prefix区分开不同的安装目录。
‘柒’ (Linux)gcc进行优化编译的参数是什么
将file.c文件编译产生可执行文件myprog(-o选项),并且在编译的时候,生成调试信息(-g信息)。让gdb调试器可以调试该程序。
gcc是编译器程序名字
-o是可执行文件名字输出参数
-g是插入调试信息参数
当然是调试可执行文件myprog
‘捌’ Linux gcc 编译参数问题
-l 使用库。
这个库的名字是 pthread 。
POSIX 线程是:线程的 POSIX标准,定义了创建和操纵线程的一套 API。
实现 POSIX 线程标准的库常被称作 Pthreads,一般用于 Unix-like POSIX 系统,如 Linux、 Solaris,但是 Microsoft Windows上的实现也存在,例如, pthreads-w32可以用于支持 Pthread API M的子集 [1]。
以上部分文字出自维基网络,故本回答的文字基于GNU自由文档许可证之条款下发布。
另外抗议网络知道封杀维基网络的连接。
‘玖’ 如何在linux下查看gcc生成的.s文件
Gcc最基本的用法是∶gcc [options] [filenames] 其中options就是编译器所需要的参数,filenames给出相关的文件名称。 -c,只编译,不连接成为可执行文件,编译器只是由输入的.c等源代码文件生成.o为后缀的目标文件,通常用于编译不包含主程序的子程序文件。 -o output_filename,确定输出文件的名称为output_filename,同时这个名称不能和源文件同名。如果不给出这个选项,gcc就给出预设的可执行文件a.out。 -g,产生符号调试工具(GNU的gdb)所必要的符号资讯,要想对源代码进行调试,我们就必须加入这个选项。 -O,对程序进行优化编译、连接,采用这个选项,整个源代码会在编译、连接过程中进行优化处理,这样产生的可执行文件的执行效率可以提高,但是,编译、连接的速度就相应地要慢一些。 -O2,比-O更好的优化编译、连接,当然整个编译、连接过程会更慢。 -Idirname,将dirname所指出的目录加入到程序头文件目录列表中,是在预编译过程中使用的参数。
‘拾’ linux下怎样给编译器设置编译的参数
编译器的参数都是编译的时候执行命令带的。
一般会写在Makefile里,直接敲make
在makefile里面 gcc -l -I -L 等等都是这样加参数的。
推荐你看一本书《linux就该这么学》书中内容非常丰富,LINUX基本问题都可以在书中解决。望采纳!
