GCC中 I L l 選項的作用

2022-07-03 14:12:10 字數 549 閱讀 4731

在makefile中經常會看到這些選項,gcc缺省會在程式當前目錄、path路徑中查詢所需要的材料

如何給gcc新增我們自己的原材料(標頭檔案,庫等)

-imyinclude
-lb
-la
整體舉例:

cc=g++

cflags=-g

bin=main

objs=main.o

libs=-i/usr/include/mysql -l/usr/lib64/mysql -lmysqlclient -ljsoncpp -lpthread -std=c++11

$(bin):$(objs)

$(cc) $(cflags) $^ -o $@

%.o:%.cpp

$(cc) $(cflags) -c $< -o $@ $(libs)

.phony:clean

clean:

rm -f *.o $(bin)

GCC編譯器中的 I L l 選項。

在本文中,我們來聊聊gcc中三個常見的引數,也即 i 大寫的i l 大寫的l 和 l 小寫的l 一.先說 i 注意是大寫的i 我們先來看簡單的程式 main.c include include add.h int main add.c int add int x,int y add.h int ad...

關於gcc編譯 I L l的使用

gcc o hello hello.c i home hello include l home hello lib lworld 引數說明 i home hello include表示將 home hello include目錄作為第乙個尋找標頭檔案的目錄,尋找的順序是 home hello inc...

gcc中的 D選項

有時候我們想在 c 原始檔中使用 makefile 中定義的某些變數,根據變數的取值做出不同的處理,比如 debug 開關 版本資訊等,這時候我們可以通過 gcc 的 d 選項來滿足這一需求,它等同於在 c 檔案中通過 define 語句定義乙個巨集。比如,我們可以在 makefile 中定義以下變...