全部。
我需要安装 gdb 才能调试一些 Fortran 90 代码。然而,我在尝试在 mac 上安装它时遇到了很多错误。
首先,我收到错误24069,我使用以下命令解决了该错误。这些命令还展示了我如何构建 gdb:
brew install --build-from-source --head domq/gdb/gdb
我的gdb版本如下所示:
GNU gdb (GDB) 15.0.50.20231019-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
我构建了一些 C++ 代码来测试 gdb 的运行方式。这是源代码:
#include <iostream>
int main(){
std::cout << "Hello World!\n";
return 0;
}
这是我的编译器和 makefile 设置:
g++-13 (Homebrew GCC 13.2.0) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
########################################################################
####################### Makefile Template ##############################
########################################################################
# Compiler settings - Can be customized.
CC = /usr/local/bin/g++-13
CXXFLAGS = -std=c++11 -arch x86_64 -ggdb -O0 -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic
LDFLAGS =
# Makefile settings - Can be customized.
APPNAME = myapp
EXT = .cpp
SRCDIR = src/include
OBJDIR = obj
############## Do not change anything from here downwards! #############
SRC = $(wildcard $(SRCDIR)/*$(EXT))
OBJ = $(SRC:$(SRCDIR)/%$(EXT)=$(OBJDIR)/%.o)
DEP = $(OBJ:$(OBJDIR)/%.o=%.d)
# UNIX-based OS variables & settings
RM = rm
DELOBJ = $(OBJ)
# Windows OS variables & settings
DEL = del
EXE = .exe
WDELOBJ = $(SRC:$(SRCDIR)/%$(EXT)=$(OBJDIR)\\%.o)
########################################################################
####################### Targets beginning here #########################
########################################################################
all: $(APPNAME)
# Builds the app
$(APPNAME): $(OBJ)
$(CC) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
# Creates the dependecy rules
%.d: $(SRCDIR)/%$(EXT)
@$(CPP) $(CFLAGS) $< -MM -MT $(@:%.d=$(OBJDIR)/%.o) >$@
# Includes all .h files
-include $(DEP)
# Building rule for .o files and its .c/.cpp in combination with all .h
$(OBJDIR)/%.o: $(SRCDIR)/%$(EXT)
$(CC) $(CXXFLAGS) -o $@ -c $<
################### Cleaning rules for Unix-based OS ###################
# Cleans complete project
.PHONY: clean
clean:
$(RM) $(DELOBJ) $(DEP) $(APPNAME)
# Cleans only all files with the extension .d
.PHONY: cleandep
cleandep:
$(RM) $(DEP)
#################### Cleaning rules for Windows OS #####################
# Cleans complete project
.PHONY: cleanw
cleanw:
$(DEL) $(WDELOBJ) $(DEP) $(APPNAME)$(EXE)
# Cleans only all files with the extension .d
.PHONY: cleandepw
cleandepw:
$(DEL) $(DEP)
当我在命令行中运行 gdb 时,我写道:
gdb ./myapp
GNU gdb (GDB) 15.0.50.20231019-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin22.6.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./myapp...
(gdb) run
Starting program: /Users/cdwalke8/Desktop/Dev/nrlmisiscpp/myapp
[New Thread 0x2503 of process 2819]
^C[Thread 0x2503 of process 2819 exited]
[New Thread 0x3f03 of process 2819]
warning: unhandled dyld version (17)
Hello World!
[Inferior 1 (process 2819) exited normally]
(gdb)
请注意,我需要按 ctrl+c 才能使其退出,然后才能正常运行。
如何解决所提供的警告?
GDB中的“警告:未处理的dyld版本(17)”通常与GDB版本和当前dyld版本之间的兼容性问题有关。要解决此警告,请考虑将 GDB 更新到支持您正在使用的特定 dyld 版本的版本。此外,请确保您的系统已更新为最新的补丁和版本,以保持 GDB 和动态链接器之间的兼容性。探索 GDB 的官方文档和社区论坛可能会提供额外的见解和潜在的解决方案来有效解决此警告。