zoukankan      html  css  js  c++  java
  • gcc编译

    gcc编译流程:
    test.c---->test.cxx(预编译)---->test.s(asm文件)---->test.o(obj文件)--->test(exe)
            (-E)                         (-S)                           (-c)                        链接

                 ---test.c
                |                    ----test_a.c
    project-|                   |
                ---h_test.h---|---test_b.c
                                    |
                                    ----test_c.c

    test.c:

    #include "so_test.h"
    int main()
    {
    test_a();
    test_b();
    test_c();
    return 0;
    }
         
    

    h_test.h

    1 //so_test.h 
    2 #include "stdio.h"
    3 void test_a();
    4 void test_b();
    5 void test_c();

    test_a.c

    1 //test_a.c 
    2 #include "so_test.h"
    3 void test_a()
    4 {
    5 printf("this is in test_a...
    ");
    6 }

    test_b.c

    1 //test_b.c 
    2 #include "so_test.h"
    3 void test_b()
    4 {
    5 printf("this is in test_b...
    ");
    6 }

    test_c.c

    //test_c.c 
    #include "so_test.h"
    void test_c()
    {
    printf("this is in test_c...
    ");
    }


    (1)gcc编译动态库

    gcc test_a.c test_b.c test_c.c -fPIC -share libtest.so
    gcc test.c -L . -ltest -o test
    ./test

    (2)gcc编译静态库

    gcc -c test_a.c test_b.c test_c.c
    ar -rv libtest.a test_a.o test_b.o test_c.o(打包)
    gcc test.c -L . -ltest -static -o test2
    ./test2

  • 相关阅读:
    Centos7安装nvidia显卡驱动
    Linux,Windows,Mac OS下换行的不同表示
    Linux权限管理问题
    Centos6.5final安装后若干问题与解决方法
    100天计划 绪
    python 变量,if,while,运算符
    python 初级重点
    py第四天
    搭建个人博客之路-01
    利用gulp+babel转es6
  • 原文地址:https://www.cnblogs.com/buyizhiyou/p/8043332.html
Copyright © 2011-2022 走看看