Linux環境程式編譯相關

2021-09-26 23:11:55 字數 524 閱讀 5789

注:以下的記錄對應64位執行環境

makefile引數解釋:

1. -i(大寫i):指定gcc/g++搜尋標頭檔案的優先搜尋路徑

gcc/g++搜尋標頭檔案的預設搜尋路徑包括:當前路徑、/usr/include、/usr/local/inlude。

.:表示當前目錄

例: -i . /usr/local/include/opencv2

搜尋順序為:當前目錄(.)-> /usr/local/include/opencv2->/usr/include/->/usr/local/include

2.-l:指定gcc/g++搜尋庫檔案的優先搜尋路徑

gcc/g++搜尋庫檔案的預設搜尋路徑包括:當前路徑、/usr/lib、/usr/lib64、/usr/local/lib、/usr/local/lib64                 

例:-l /usr/local/bin64/opencv2

gcc/g++會優先搜尋/usr/local/bin64/opencv2路徑,然後才會搜尋預設路徑

在linux環境下編譯C 程式

下面是乙個儲存在檔案helloworld.cpp中乙個簡單的 c 程式的 單個原始檔生成可執行程式 helloworld.cpp include int main int argc,char argv 程式使用定義在標頭檔案 iostream 中的 cout,向標準輸出寫入乙個簡單的字串。該 可用以...

在linux環境下編譯C 程式

下面是乙個儲存在檔案helloworld.cpp中乙個簡單的 c 程式的 單個原始檔生成可執行程式 helloworld.cpp include int main int argc,char ar 程式使用定義在標頭檔案 iostream 中的 cout,向標準輸出寫入乙個簡單的字串。該 可用以下命...

Linux環境下使用CMake編譯程式

mkdir build cd build cmake g unix makefiles make d巨集名 on,設定option開關 dcmake build type debug 新增除錯資訊 方法一 要在呼叫add x指令前設定該變數,否則不起作用 set cmake install rpat...