如何在MacPorts gcc 4.5中调试C ++ 0x程序? [英] How do I debug C++0x programs in MacPorts gcc 4.5?

查看:173
本文介绍了如何在MacPorts gcc 4.5中调试C ++ 0x程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的c ++程序,我正在尝试调试,但gdb无法找到这些库的目标文件(或者没有调试信息可用),它似乎也无法找到我的可执行文件的调试符号。

I have a simple c++ program I am trying to debug, but gdb cannot find the object file for the libraries (or no debug info is available), and it does not seem able to find the debug symbols for my executable either.

我在OSX 10.5.8上使用macports,并使用

I am on OSX 10.5.8, with macports, and I compile my code with

$ b $编译我的代码b

g ++ - mp-4.5 -Wall -pedantic -std = c ++ 0x -g -ggdb -I / opt / local / include -L / opt / local / lib -lgsl
-static-libstdc ++ MCMC-simplex.cpp -o mcmc

g++-mp-4.5 -Wall -pedantic -std=c++0x -g -ggdb -I/opt/local/include -L/opt/local/lib -lgsl -static-libstdc++ MCMC-simplex.cpp -o mcmc

(只有一个文件,g ++ - mp-4.5是gcc的macports可执行文件/ g ++ 4.5)

(there is only one file, and g++-mp-4.5 is the macports executable for gcc/g++ 4.5 )

当我尝试在生成的可执行文件上运行gdb时,我收到很多错误消息(在启动时)

When I try running gdb on the resulting executable, I get many error messages (at startup) of the form


警告:找不到目标文件/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_gcc45/work/build/i386-apple-darwin9/libgcc/ trunctfdf2_s.o - 没有调试信息可用于../../。 ./gcc-4.5.0/libgcc/../ gcc / config / soft-fp / trunctfdf2.c。

warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_gcc45/work/build/i386-apple-darwin9/libgcc/trunctfdf2_s.o" - no debug information available for "../../../gcc-4.5.0/libgcc/../gcc/config/soft-fp/trunctfdf2.c".

其中对我来说,macports在构建过程中有一个bug(看起来gdb正在寻找临时构建目录中的对象文件)。

which to me indicates that macports has a bug during its build (it seems like gdb is looking for the object files in the temporary build directory).

我应该补充一点,当我尝试在gdb(Apple提供的程序)中查看我的程序,它会尝试在 / var / tmp中随机查找 .s 文件,这对我来说听起来像一个汇编程序文件。这就是为什么我说它似乎无法找到我的程序的调试符号。

I should add that when I try to see my programs listing in gdb (the one provided by Apple), it tries to look for a random .s file in /var/tmp, which to me sounds like an assembler file. That is why I say it does not seem able to find the debug symbols for my program either.

当我尝试MacPorts gdb 7.1时,我得到

When I try MacPorts gdb 7.1, I get


警告:`/var/folders/Xa/XaqHO9PeEC8K-Nrd0L9xWk+++TM/-Tmp-//cc2IvFto.o':无法阅读符号:没有这样的文件或目录。
(找不到调试符号)... done。

warning: `/var/folders/Xa/XaqHO9PeEC8K-Nrd0L9xWk+++TM/-Tmp-//cc2IvFto.o': can't open to read symbols: No such file or directory. (no debugging symbols found)...done.

并且Apple的gdb给出的许多错误消息都没有(尽管最终结果是相同的)。

and none of the many error messages that Apple's gdb gives out (although the end result is the same).

有没有人遇到过这个问题,并提出了解决方案?

Has anyone come across this problem, and came up with a solution?

推荐答案

好吧,继续使用单个编译链接步骤的另一个技巧是添加

- save-temps = obj


到您的g ++命令行,以便

Well, another "trick" to keep going with a single compile-and-link step would be to add
-save-temps=obj
to your g++ command line so that


4删除/tmp/[random-string].o和.s

4 Remove /tmp/[random-string].o and .s

实际上有些没有执行(实际上你最终有规范SOURCE.o和SOURCE.s文件在您正在构建的目录中,而不是RANDOM-STRING。[os]在一些临时文件夹中,但是从查找调试符号的角度来看很好

is actually sort of not performed (actually you end up having the canonical SOURCE.o and SOURCE.s files in the directory where you're building instead of RANDOM-STRING.[os] in some temp folders, but from the point of view of locating debugging symbols that's fine

这篇关于如何在MacPorts gcc 4.5中调试C ++ 0x程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆