zoukankan      html  css  js  c++  java
  • 关于静态与动态编译arm平台程序的比較

    因为近期弄个console程序,调用了readline,ncurses库,这两个动态库加起来有四百多k。而程序事实上非常小,其它地方也没使用到这两个库

    所以想静态编译看看console程序有多大。

    #arm-linux-gcc cli.c -o console libreadline.a  libncurses.a

     #ls -l

    total 1932
    -rwxrwxr-x 1 root root   8427 Jul  7 15:19 cli
    -rw-r--r-- 1 root root   6647 Jul  7 17:57 cli.c
    -rwxr-xr-x 1 root root 624681 Jul  8 15:00 console
    -rw-r--r-- 1 root root 108398 Jul  7 16:05 libhistory.a
    -rw-r--r-- 1 root root 433720 Jul  7 17:09 libncurses.a
    -rw-r--r-- 1 root root 780788 Jul  7 16:05 libreadline.a

    一看有六百多k。貌似大了点,加上-s试试

    # arm-linux-gcc cli.c -o console libreadline.a  libncurses.a  -s

    # ls -l
    total 1576
    -rwxrwxr-x 1 root root   8427 Jul  7 15:19 cli
    -rw-r--r-- 1 root root   6647 Jul  7 17:57 cli.c
    -rwxr-xr-x 1 root root 259323 Jul  8 15:03 console
    -rw-r--r-- 1 root root 108398 Jul  7 16:05 libhistory.a
    -rw-r--r-- 1 root root 433720 Jul  7 17:09 libncurses.a
    -rw-r--r-- 1 root root 780788 Jul  7 16:05 libreadline.a

    剩下260多k这样。貌似能接受。


    回过来再看看动态库链接下的console程序

    #arm-linux-gcc cli.c -o console -lreadline -lncurses 

    # ls -l
    total 1332
    -rwxrwxr-x 1 root root   8427 Jul  7 15:19 cli
    -rw-r--r-- 1 root root   6647 Jul  7 17:57 cli.c
    -rwxr-xr-x 1 root root  10445 Jul  8 15:12 console
    -rw-r--r-- 1 root root 108398 Jul  7 16:05 libhistory.a
    -rw-r--r-- 1 root root 433720 Jul  7 17:09 libncurses.a
    -rw-r--r-- 1 root root 780788 Jul  7 16:05 libreadline.a

    10.2k的样子。加上动态库也就四百多k


    再进一步加上-s试试

    #arm-linux-gcc cli.c -o console -lreadline -lncurses -s

    # ls -l
    total 1328
    -rwxrwxr-x 1 root root   8427 Jul  7 15:19 cli
    -rw-r--r-- 1 root root   6647 Jul  7 17:57 cli.c
    -rwxr-xr-x 1 root root   6839 Jul  8 15:13 console
    -rw-r--r-- 1 root root 108398 Jul  7 16:05 libhistory.a
    -rw-r--r-- 1 root root 433720 Jul  7 17:09 libncurses.a
    -rw-r--r-- 1 root root 780788 Jul  7 16:05 libreadline.a

    6.7k的样子,事实上程序是非常小的一个。程序库倒是非常大一坨。










  • 相关阅读:
    P2P学习(三)网络传输基本知识---TURN协议
    P2P学习(三)网络传输基本知识---STUN协议(二)
    P2P学习(三)网络传输基本知识---STUN协议(一)
    P2P学习(三)网络传输基本知识
    P2P学习(二)P2P中的NAT穿越(打洞)方案详解
    如何画UML时序图
    数据大屏、报表设计器等
    SQL Server查询指定表的操作记录
    ORACLE查询当前用户的权限
    InfluxDB:集群版使用指南(Influx-proxy)
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5132487.html
Copyright © 2011-2022 走看看