error when including iostream

Started by
12 comments, last by ApochPiQ 12 years ago
I'm getting a runtime error when I include iostream in my program. This is the error:

Program received signal SIGSEGV, Segmentation fault.
In ntdll!RtlpWaitForCriticalSection () (C:\WINDOWS\system32\ntdll.dll)

I'm using Code::Blocks on windows XP.
Any ideas on how to fix this?
Advertisement
How have you deduced that it is the inclusion of <iostream> that is causing this? Does the following program work?


#include <iostream>
int main() { return 0; }
I tried that code and it doesn't work. But it works if I comment the including of iostream.
Something is seriously bork'd. Have you recently installed the IDE? What versions of code::blocks and compiler are you using? Can you get a stack trace of where the segfault occurs?
I installed the IDE yesterday. I'm using Code::Blocks release 10.05 rev 6283. Here is the stack trace:

#0 7C91B1FA ntdll!RtlpWaitForCriticalSection() (C:\WINDOWS\system32\ntdll.dll:??)
#1 7C901046 ntdll!RtlEnumerateGenericTableLikeADirectory() (C:\WINDOWS\system32\ntdll.dll:??)
#2 00000000 0x00dae7b0 in ??() (??:??)
#3 77C3B90D msvcrt!_lock() (C:\WINDOWS\system32\msvcrt.dll:??)
#4 77C3EF1A msvcrt!fflush() (C:\WINDOWS\system32\msvcrt.dll:??)
#5 73DAE790 iob() (C:\WINDOWS\system32\crtdll.dll:??)
#6 00000000 0x00000020 in ??() (??:??)
#7 00000000 0x002541b0 in ??() (??:??)
#8 00000000 0x00000001 in ??() (??:??)
#9 00000000 0x00000001 in ??() (??:??)
#10 00000000 0x0022fe14 in ??() (??:??)
#11 00000000 0x0046c2f0 in __DTOR_LIST__() (??:??)
#12 00000000 0x0022ffe0 in ??() (??:??)
#13 77C35C94 msvcrt!_except_handler2() (C:\WINDOWS\system32\msvcrt.dll:??)
#14 00000000 0x0044611f in std::ostream::flush() (??:??)
Which compiler are you using?

I don't believe that Visual C++ 2012 can build Windows XP applications without some semi-serious link-time hackery, in case you happen to be using a pre-release of that.
I'm using mingw compiler 4.4.1-tdm-2.
Can you compile a simple application on the command line that behaves properly? e.g.

C:\path\to\g++ main.cpp -o main.exe -ansi -pedantic

Does 4.4.1-tdm-2 come with Code::Blocks? There are more recent versions of g++ from the official MinGW distribution.
I tried compiling from the command line with the example you gave me and it worked.
Yes, that compiler came with Code::Blocks.
Ok, so what command line is Code::Blocks using to compile/link?

This topic is closed to new replies.

Advertisement