理解gcc编译

#正常使用的一步编译
gcc hellogcc.c -o hgcc

gcc -I/home/train hellogcc.c -o h2 

#a.分步进行
gcc -c star.c -o star.o
gcc -c hello.c -o hello.o
gcc hello.o star.o -o mypro
#b 一步编译
gcc star.c hello.c -o mypro1

#不显示警告
gcc -w star.c hello.c -o mypro1
#显示所有警告
gcc -Wall star.c hello.c -o mypro1

#a.生成动态链接库
gcc -fpic -shared -s hello.c -o libhello.so
file libhello.so
sudo cp libhello.so /usr/lib #讲库放到系统路径
gcc -lhello star.c -o myprolib
ldd myprolib

#b使用静态库
gcc -c hello.c -o hello.o
ar -rc libhello.a hello.o 
#ar t libhello.a 
gcc star.c -L /home/train/linux_c/day_2/doit -lhello -o mystar
./mystar


#gdb调试
gcc -g new.c -o new
gdb new
    list
    run
    break 8
    break 14
    break 18 
    info break
    run
    next
    continue
    info local
    print s #根据变量名称打印其信息
    continue
    quit
此条目发表在C分类目录。将固定链接加入收藏夹。

发表评论

邮箱地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Protected with IP Blacklist CloudIP Blacklist Cloud