在 Ubuntu 上使用 gdb 调试 Code::Blocks 时出现问题
我刚刚开始进行 C++ 编程,首先使用 ms Visual c++,然后使用 Code::Blocks。
问题是,在我的计算机上,运行 Ubuntu,Code::Blocks“开箱即用”无法调试,即使是默认的“hello world”,它也只是跳过所有断点并完成程序。
我有一台使用 Sun 的 VirtualBox 的虚拟化 Windows 机器,我放置在那里的窗口 Code::Blocks 运行得很好,“开箱即用”!
ubuntu 上的程序在我尝试调试时显示:找不到名为“a/b/c”的命名空间、类、结构或联合的成员,其中a/b/c 是我正在构建的程序所在的路径。
这就是调试器日志中显示的内容:
构建以确保源是最新的
构建成功
选择目标:
调试
添加源目录:/home/arnau/Documents/UNI/compus/Code::Blocks/opo/
添加源目录:/home/arnau/Documents/UNI/compus/Code::Blocks/opo/
添加文件:bin/Debug/opo
启动调试器:
完成
注册新类型:wxString
注册新类型:STL String
注册新类型:STL Vector
设置断点
调试器名称和版本:GNU gdb 6.8-debian
找不到名为“/home/arnau/Documents/UNI/compus/Code::Blocks/opo/main.cpp 的命名空间、类、结构或联合的成员:8"
提示:尝试 '"/home/arnau/Documents/UNI/compus/Code::Blocks/opo/main.cpp:8 或 '"/home/arnau/Documents/UNI/compus/Code::Blocks/opo/main .cpp:8
(注意前导单引号。)
程序正常退出。
调试器已完成,状态为 0
谢谢您的宝贵时间,我真的很感激。
阿尔诺,来自巴塞罗那
I just started programming C++, first in ms Visual c++, then in Code::Blocks.
The problem is that on my computer, running Ubuntu, Code::Blocks "out of the box" does not debug, even the default "hello world", it just skips all breakpoints and finishes the program.
I have a virtualized Windows machine using Sun's VirtualBox and the window's Code::Blocks that I put there runs great "out of the box"!.
the program on ubuntu, shows this when I try to debug: Can't find member of namespace, class, struct, or union named "a/b/c" where a/b/c is the path to where the program I am building is.
that's what appears on the debugger log:
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: /home/arnau/Documents/UNI/compus/Code::Blocks/opo/
Adding source dir: /home/arnau/Documents/UNI/compus/Code::Blocks/opo/
Adding file: bin/Debug/opo
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.8-debian
Can't find member of namespace, class, struct, or union named "/home/arnau/Documents/UNI/compus/Code::Blocks/opo/main.cpp:8"
Hint: try '"/home/arnau/Documents/UNI/compus/Code::Blocks/opo/main.cpp:8 or '"/home/arnau/Documents/UNI/compus/Code::Blocks/opo/main.cpp:8
(Note leading single quote.)
Program exited normally.
Debugger finished with status 0
Thank you for your time, I really appreciate that.
Arnau, from Barcelona
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您对源目录的命名:
.../Code::Blocks/...
是非常不幸的。虽然 UNIX 允许文件名中包含除
'/'
和NUL
之外的任何字符,但使用':'
是不明智的,因为这是一个PATH
分隔符,并且您将无法将/home/arnau/Documents/UNI/compus/Code::Blocks/opo
添加到您的PATH< /代码>。
在
GDB
中,':'
还有两个附加含义——文件名和行号(或函数名)之间的分隔符,和 < code>'::' 作为范围指示符(处理C++
所需)。摘要:将
“Code::Blocks”
目录重命名为codeblocks
,从此幸福快乐地生活。Your naming of the source directory:
.../Code::Blocks/...
is most unfortunate.While UNIX allows any character in a filename, except
'/'
andNUL
, it is unwise to use':'
, because that is aPATH
separator, and you would not be able to add e.g./home/arnau/Documents/UNI/compus/Code::Blocks/opo
to yourPATH
.In
GDB
there are two additional meanings of':'
-- the separator between file name and line number (or function name), and'::'
as a scope indicator (required for handlingC++
).Summary: rename
"Code::Blocks"
directory tocodeblocks
, and live happily ever after.