關於靜態與動態編譯arm平台程式的比較

來源:互聯網
上載者:User

標籤:arm   readline   ncurses   

由於最近弄個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的樣子,其實程式是很小的一個,程式庫倒是很大一坨。










聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.