day01

今天大概瀏覽了下《UnixProgrammingTools》, 知道了一下幾方面的基本知識(shí)。

  • gcc編譯器的使用
  • make

gcc

學(xué)習(xí)了gcc的基本指令,以前只知道-c、-o的用法,此次學(xué)會(huì)了更多的指令

  • -g

增加調(diào)試信息,方便使用gdb進(jìn)行調(diào)試

  • -Wall

在源代碼中可能出錯(cuò)的地方給出警告

  • -Idir

添加頭文件所在的路徑

  • -Ldir

添加庫(kù)文件所在的路徑

  • -lmylib

添加庫(kù)文件的名稱,注意庫(kù)文件的順序,被依賴的文件必須放在依賴文件之前

make

使用make工具可以大大減少編譯、鏈接時(shí)的工作量。

makefile文件

變量

makefile中的變量相當(dāng)于C語(yǔ)言中的宏。當(dāng)沒(méi)有對(duì)一個(gè)變量賦值時(shí),其值為空。變量的使用方法如下,eg:

定義變量:CC = gcc
使用變量:$(CC)

dependency/build rule

A rule tells how to make a target based on changes to a list of certain files. The order of rules does not make any difference, except that the first rule is consider to be the default rule -- the rule that will be invoked when make is called without any arguments (the most common way).

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容