1. 程式人生 > >Linux使用原始碼包安裝軟體

Linux使用原始碼包安裝軟體

前言:

最近整理一些以前的學習筆記。
過去都是儲存在本地,此次傳到網路留待備用。


 

原始碼包

  • Linux軟體多數免費、開源,是開發人員編寫的,具有很強可讀性的一組相關程式碼文字。
  • 原始碼包 --> 編譯 --> 二進位制包
  • 二進位制的安裝軟體格式: exe、deb、msi、rpm...
  • 原始碼安裝的優點:

    • 獲得軟體的最新版本,及時修復bug
    • 軟體功能可按需選擇/定製,有更多軟體可供選擇
    • 原始碼包適用於各種平臺
  • 原始碼安裝的缺點:

    • 沒辦法自定義
    • 封裝二進位制包將花費大量時間

 

原始碼包的安裝步驟

1.檢測配置,設定選項
]# ./configure
2.編譯二進位制

]# make
3.安裝
make install


 

原始碼包安裝例項

1.下載原始碼包

]# wget https://sourceforge.net/projects/inotify-tools/files/latest/download/inotify-tools-3.13.tar.gz

2.解壓原始碼包

]# tar -xf inotify-tools-3.13.tar.gz
]# cd inotify-tools

3.檢測並配置環境選項

]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make sets $(MAKE)... (cached) yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

]# yum -y install gcc
]# ./configure --prefix=/opt/inotify

4.編譯二進位制

]# make             #在./configure不報錯的情況下執行

5.安裝編譯後的二進位制檔案

]# make install
  • 檢驗

    ]# /opt/inotify/bin/inotifywait /mnt/           #可以正常執行
    Setting up watches.  
    Watches established.