簡體   English   中英

g++ -g 選項僅在 makefile 中不起作用

[英]g++ -g option is not working only in makefile

奇怪的是,我的 makefile 中的 -g 不起作用。 可能它使用不同的 g++ 版本?

這是我的 makefile

.default: all

all: linkedlist

clean:
    rm -f linkedlist *.o

linkedlist: main.o list.o
    g++ -Wall -Werror --std=c++14 -g -O -o $@ $^

%.0: %.cpp
    g++ -Wall -Werror --std=c++14 -g -O -c $^

這是 output:

╰ make
c++    -c -o main.o main.cpp
c++    -c -o list.o list.cpp
g++ -Wall -Werror --std=c++14 -g -O -o linkedlist main.o list.o

但它不適用於我的lldb。 但是,如果我手動生成它

g++ -Wall -Werror -g --std=c++14 -O -o linkedlist list.cpp main.cpp ,我的調試器工作,我還注意到它生成linkedlist.dSYM文件夾(與makefile它沒有) . 我不確定,但我認為在上周更新我的 xcode 之前,我在使用 -g 生成二進制文件時從未見過.dSYM 文件。

知道為什么嗎?

干杯

G++ 版本:

╰ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

你的 Makefile 有錯誤

%.0: %.cpp

應該

%.o: %.cpp

字母“o”,而不是數字零。

由於這個錯誤,您使用默認規則編譯 C++ 代碼,並且那些不包含-g選項,並且可能使用不同的編譯器 c++ 與 Z644B1F5211D64EC52727780E74026F6E。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM