2

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
Community
  • 1
  • 1
Grr
  • 15,553
  • 7
  • 65
  • 85
  • When you hit the SIGSEGV in gdb, type `bt` to get a backtrace - that will then tell you where in your program you called the math library from and that may be enough for you to find your bug. – Paul R Aug 14 '15 at 14:40
  • @PaulR Thanks for the tip. I had tried this before but unfortunately I dont really know how to read this output. What I get is as follows: `#0 0x6fc842f4 in libstdc++-6!_ZNSi6sentryC1ERSib () from C:\Users\Me\Desktop\libstdc++-6.dll #1 0x6fc84dcf in libstdc++-6!_ZNSirsERi () from C:\Users\Me\Desktop\libstdc++-6.dll #2 0x00401462 in _fu3___ZSt3cin () #3 0x0028ff14 in ?? () #4 0x00401250 in __mingw_CRTStartup () #5 0x004012b5 in mainCRTStartup ()` Is it possible the error is in #3 the ?? () or is it with the #0 step which reiterates the segmentation fault error. – Grr Aug 14 '15 at 15:02
  • OK - it looks like it's crashing in the runtime code, before it even gets to main(), so it's probably not a bug in your code. Does this happen even with a simple "hello world" program when you add the math library ? – Paul R Aug 14 '15 at 15:38
  • @PaulR No. It works with 'Hello world", but whenever I add in any methods from it crashes. My gut tells me its something wrong with the g++ setup on my machine but I really don't know. – Grr Aug 14 '15 at 16:40
  • 1
    post the smallest possible failing code along with the commands used to compile and link – pm100 Aug 14 '15 at 19:57
  • I have no problems with your code (using gcc 4.6.2). Maybe cmath is being included from somewhere unexpected? Check the include paths by running `echo | C:\mingw\bin\cpp -Wp,-v`. – ioums Aug 14 '15 at 20:27
  • @ioums What should i be looking for in there? At the end of the output there is a section that starts with `#include "..." search starts here:` and `#include "<...>" search starts here:` This is followed by `c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include` `c:\mingw\bin\../lib/gcc/mingw32/4.8.1/../../../../include` `c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include-fixed` `c:\mingw\bin\../lib/gcc/mingw32/4.8.1/../../../../mingw32/include` `End of search list.` `cc1.exe: error: too many filenames given. Type cc1.exe --help for usage` – Grr Aug 15 '15 at 13:14

0 Answers0