[英]g++ -g option is not working only in makefile
Weirdly -g in my makefile is not working.奇怪的是,我的 makefile 中的 -g 不起作用。 Possibly its using different g++ version?可能它使用不同的 g++ 版本?
Here's my makefile这是我的 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 $^
Here's the output:这是 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
But it doesn't work with my lldb.但它不适用于我的lldb。 However if i generate it manually但是,如果我手动生成它
g++ -Wall -Werror -g --std=c++14 -O -o linkedlist list.cpp main.cpp
, my debugger works and I also notice that it generates linkedlist.dSYM
folder (with the makefile it doesn't). g++ -Wall -Werror -g --std=c++14 -O -o linkedlist list.cpp main.cpp
,我的调试器工作,我还注意到它生成linkedlist.dSYM
文件夹(与makefile它没有) . I'm not sure but I think before I updated my xcode last week, I never saw.dSYM file when generating binaries with -g.我不确定,但我认为在上周更新我的 xcode 之前,我在使用 -g 生成二进制文件时从未见过.dSYM 文件。
Any idea why?知道为什么吗?
Cheers干杯
G++ Version: 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
You have a mistake in your Makefile你的 Makefile 有错误
%.0: %.cpp
should be应该
%.o: %.cpp
The letter 'o', not the number zero.字母“o”,而不是数字零。
Because of this mistake you were using the default rules for compiling C++ code, and those didn't include the -g
option, and potentially are using a different compiler, c++ vs g++.由于这个错误,您使用默认规则编译 C++ 代码,并且那些不包含-g
选项,并且可能使用不同的编译器 c++ 与 Z644B1F5211D64EC52727780E74026F6E。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.