使用 -g 选项编译,但"Single stepping until exit from function main, which has no line number information"
Compile with -g option but "Single stepping until exit from function main, which has no line number information"
我在gdb方面遇到了一些问题。这是我在一个名为main.cpp 的文件中的代码
#include <iostream>
void myfunc();
int main(){
char msg[] = "Hello World!";
myfunc();
std::cout << msg << std::endl;
return 0;
}
void myfunc(){
int boo = 16;
}
我用这个命令编译了这个代码:
g++ -g -Wall main.cpp -o foo
接下来,我使用gdb:
$ gdb foo
(gdb) start
Temporary breakpoint 1 at 0x80487c3
Starting program: /home/laptop/workspace/foo
Temporary breakpoint 1, 0x080487c3 in main ()
(gdb) s
Single stepping until exit from function main,
which has no line number information.
Hello World!
__libc_start_main (main=0x80487c0 <main>, argc=1, ubp_av=0xbffff3a4, init=0x80488b0 <__libc_csu_init>, fini=0x8048920 <__libc_csu_fini>, rtld_fini=0xb7fed280 <_dl_fini>, stack_end=0xbffff39c) at libc-start.c:258
258 libc-start.c: No such file or directory.
我做错了什么?我使用了-g选项,但仍然出现了这个错误。
配置:
- GDB:GNU GDB(Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1)7.4-2012.04
- GCC:g++(Ubuntu 4.8.1-2ubuntu1~12.04)4.8.1
我安装了这些工具与一个经典:sudo apt-get-install
提前感谢您的任何回答:-)
感谢您的回答。我发现了问题所在。正如jcm所说,我的gcc相对较新。我已经将gdb更新到最新版本,即GNU gdb(gdb)7.6。现在这很好用。
顺便说一句,对于g++版本(Ubuntu/Linaro 4.6.4-1ubuntu1~12.04)4.6.4,gdb(Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1)7.4-2012.04运行得很好。
谢谢大家。
使用-g
和-ggdb
标志编译。
你的命令应该是
g++ -g -ggdb -Wall main.cpp -o foo
也尝试使用'-Og'。也许这会有所帮助,因为正如@KevinDTimm所写:编译器可能会优化它
参考:
- "c++--help=优化器"
相关文章:
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- 代码在main()中运行,但在函数中出现错误
- 当我在main中声明了我的2d数组时,为什么我的程序会退出
- QML:修改在不同QML文件(而非main.QML)中定义的子对象的属性
- 不确定要在我的main中放入什么才能使我的代码正常工作
- 函数是否可以访问传递给main()的参数
- 在main()之外初始化std::vector会导致性能下降(多线程)
- 我的 int main() 中出现堆栈溢出错误
- C++变量名(可以将 main 声明为变量,但对于其他函数名称则不然)
- 当我尝试在 Main 中调用插入函数时,它不是取数字?
- File.cpp.o:OpenPose 标志 CMakeFiles/.. 的多重定义/main.cpp.o:首先在这里定
- std::unordered_map 类型对象声明期间出现"field has incomplete type"错误
- 为什么类和 main() 函数中也有动态内存分配
- 在 main.cpp 的上下文中找不到目录(带有 CMake 的快板)
- 我想在 Main 中用 C++ 调用其他类中的一个类,但我做不到
- "main"函数堆栈中的对象在第一个任务运行时被覆盖 (FreeRTOS)
- 为什么 'main' 函数中的局部 int 变量会自动初始化?
- C++ assigment std::list:<typename>:itrator 在 main 中工作,但在方法中它不起作用
- 为什么在我的 main 函数中声明整数后我的整数数组中会出现错误?
- 使用 -g 选项编译,但"Single stepping until exit from function main, which has no line number information"