找到你要的答案

Q:cmath library causing runtime error in C++

Q:cmath图书馆造成C++运行时错误

DISCLAIMER: I'm not an expert or professional and am simply teaching myself. So my attempts to solve this may have been rudimentary at best.

In C++, whenever I try to compile a program using the <cmath> library, compiling will complete, but when the program attempts to execute I get a runtime error. A Windows dialogue box pops up saying the program has stopped working and is searching for a solution. Instead of just asking you folks, I figured I would try to learn a bit and give it my best shot first. So I loaded up GDB and tried running the program with that to shed a little more light on what is going on.

When running a program including the <cmath> library, GDB immediately outputs the following (regardless of where I place the breakpoint):

warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\AE_MailSensor_Plugin.dll.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\ame_outlooksensor.dll.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\ame_smtpsensor.dll.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\OS_Plugin.dll.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\COM_sensor.dll.
Do you need "set solib-search-path" or "set sysroot"?

If I place the breakpoint on main it stops here. If I allow it to run without a breakpoint or instruct GDB to move to the next step I receive:

Program received signal SIGSEGV, Segmentation fault.
0x6fc85cd1 in libstdc++-6!_ZNSo9_M_insertIdEERSot_ ()
    from C:\Users\Me\Desktop\libstdc++-6.dll

From what I can gather, it looks like for some reason my system is having an issue loading the <cmath> library, but I'm still not really sure why. The first three warnings look like files related to e-mail processes, but that makes very little sense to me (but again I don't know very much). So that's about where I'm stuck.

FYI: I am running Windows 7 enterprise, using MinGW and G++ for my compiler.

EDIT: I have tried compiling the program with debug symbols enabled by using -g. When doing this the backtrace is reduced to only #0, #1, and #2 (see comment below for original backtrace) with #2 appended by `at C:\Users\me\desktop\file.cpp: 19. Indicating line 19 which is the last step before the method. This case is repeated in more simple programs with the line indicated being the last step before a method is called.

Is it possible there is a version issue going on akin to this question which points to this forum thread? I'm using gcc version 4.8.1

EDIT: per request of @pm100. code:

#include <cmath>
#include <iostream>
using namespace std;

int main() {
  cout << floor(2.3);
}

for compiling: (i am using notepad++)

NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\mingw\bin\g++ "$(FULL_CURRENT_PATH)" -o "$(NAME_PART).exe" -g
cmd /c $(NAME_PART).exe

声明:我不是专家或专业,我只是教自己。所以我试图解决这个问题可能是最基本的。

在C++中,每当我试图使用<编译一个程序;cmath >;图书馆,编制完成,但当程序试图执行我会得到一个运行时错误。一个窗口对话框弹出说,该程序已停止工作,正在寻找解决方案。我不只是问你,我想我会尝试学习一点,让我最好的镜头。所以我把GDB和试运行的程序,在什么流一点光。

运行一个程序时包括<;cmath >;图书馆,GDB立即输出以下(无论在哪里,我把断点):

warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\AE_MailSensor_Plugin.dll.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\ame_outlooksensor.dll.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\ame_smtpsensor.dll.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\OS_Plugin.dll.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for C:\Program Files\DGAgent\plugins\09D849B6-32D3-4A40-85EE-6B84BA29E35B\COM_sensor.dll.
Do you need "set solib-search-path" or "set sysroot"?

如果我把断点放在它的主停止这里。如果我允许它运行没有断点或指导GDB移动到下一步我接受:

Program received signal SIGSEGV, Segmentation fault.
0x6fc85cd1 in libstdc++-6!_ZNSo9_M_insertIdEERSot_ ()
    from C:\Users\Me\Desktop\libstdc++-6.dll

从我所能搜集,似乎因为某种原因我的系统有一个问题,加载<;cmath >;图书馆,但我还真的不知道为什么。前三个警告看起来像与电子邮件进程相关的文件,但这对我来说意义不大(但我不太清楚)。所以这就是我被卡住的地方。

供参考:我是Windows 7的企业运行,使用MinGW和G + +我的编译器。

编辑:我试着编译程序调试符号使用·当这样的回溯是减少到只有0 # #,1,和2 #(见下面评论原始回溯)与# 2附加` C:\用户\我\桌面\ file.cpp:19。指示线19是最后一步之前的方法。这种情况是重复在更简单的程序,该行表示的最后一步之前的方法被称为。

是否有可能有一个版本的问题,类似于这个问题指向这个论坛线程?我使用gcc版本4.8.1

EDIT: per request of @pm100. code:

#include <cmath>
#include <iostream>
using namespace std;

int main() {
  cout << floor(2.3);
}

编译:(我用记事本+ +)

NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\mingw\bin\g++ "$(FULL_CURRENT_PATH)" -o "$(NAME_PART).exe" -g
cmd /c $(NAME_PART).exe
c++  debugging  segmentation-fault  cmath