文本關鍵字:Linux、軟件管理、configure、make、make install前端
不少軟件下載以後是一個源碼包,是不可以直接運行的,須要先進行編譯安裝,生成可執行程序。在進行編譯時,須要先使用yum安裝編譯工具。nginx
必需要安裝的就是gcc(GNU Compiler Collection)GNU編譯器套件,其中包含了C、C++、Objective-C、Fortran、Java、Ada、Go語言前端,也包含了對應語言的庫,幾乎能夠知足絕大部分源碼軟件對編譯環境的須要。bash
yum install gcc
安裝後可解決如下問題:curl
在進行實際軟件安裝時,因爲軟件與軟件之間可能也會存在依賴和調用關係,如:在源碼編寫時引入了某個類庫,若是咱們的系統中沒有相關的類庫,就會編譯失敗,這個時候咱們只要根據報錯信息安裝相應的缺失類庫便可,如下列出了一些經常使用的類庫。ide
./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.
yum install pcre-devel
./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option.
yum install zlib-devel
src/main.c:18:23: 錯誤:curl/curl.h:沒有那個文件或目錄 src/main.c: 在函數‘main’中: src/main.c:143: 警告:隱式聲明函數‘curl_global_init’ src/main.c:143: 錯誤:‘CURL_GLOBAL_ALL’未聲明(在此函數內第一次使用) src/main.c:143: 錯誤:(即便在一個函數內屢次出現,每一個未聲明的標識符在其 src/main.c:143: 錯誤:所在的函數內也只報告一次。) src/main.c:397: 警告:隱式聲明函數‘curl_global_cleanup’ make: *** [src/main.o] 錯誤 1
yum install curl-devel
yum install openssl openssl-devel
編譯安裝的第一步與解壓安裝相似,須要先進行解壓縮,通常都會包含如下目錄和內容。函數
編譯安裝的第一步就是執行configure腳本,會檢查編譯構建當前軟件的所需環境,同時用戶能夠根據須要指定相關的配置。全部的選項以--開頭使用等號鏈接配置項與配置的值,如:--prefix=/usr/local/。工具
在不指定安裝位置時,將會安裝到默認位置,一般分佈在/usr/local中ui
在進行configure後,若是環境不存在問題,會生成對應的Makefile文件,用於執行make命令時調用。url
在make事後,其實軟件已經完成了安裝,會在源碼解壓目錄中生成構建完成的文件,如:Nginx軟件make後會在obj文件夾中生成以下文件:3d
編譯後可使用make test或make check命令再次檢查編譯過程是否正確。
執行最後一步:編譯安裝,根據configure階段的配置,將已經生成的軟件安裝到指定的目錄中去,能夠對可執行文件定義軟鏈接或者添加到環境變量,方便使用。