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的样子,事实上程序是非常小的一个。程序库倒是非常大一坨。










  • 相关阅读:
    EntityFramework 在实际开发做项目架构的一点疑问
    应用运筹学4Danzig Wolfe Decomposition
    应用运筹学2 约束优化
    应用运筹学3Benders Decomposition
    应用运筹学1 变量使用
    11组Beta冲刺5/5
    11组Beta冲刺3/5
    11组Beta冲刺4/5
    11组Alpha冲刺总结
    11组Beta冲刺1/5
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5132487.html
Copyright © 2011-2022 走看看