Jump to content

  • Log In with Google      Sign In   
  • Create Account


error when including iostream


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
13 replies to this topic

#1 Devil0150   Members   -  Reputation: 153

Like
0Likes
Like

Posted 05 April 2012 - 12:44 PM

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?


Sponsor:

#2 e‍dd   Members   -  Reputation: 2105

Like
0Likes
Like

Posted 05 April 2012 - 08:04 PM

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; }


#3 Devil0150   Members   -  Reputation: 153

Like
0Likes
Like

Posted 06 April 2012 - 06:28 AM

I tried that code and it doesn't work. But it works if I comment the including of iostream.


#4 rip-off   Moderators   -  Reputation: 8072

Like
0Likes
Like

Posted 06 April 2012 - 07:09 AM

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?

#5 Devil0150   Members   -  Reputation: 153

Like
0Likes
Like

Posted 06 April 2012 - 07:19 AM

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() (??:??)


#6 e‍dd   Members   -  Reputation: 2105

Like
0Likes
Like

Posted 06 April 2012 - 09:52 AM

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.

#7 Devil0150   Members   -  Reputation: 153

Like
0Likes
Like

Posted 06 April 2012 - 01:46 PM

I'm using mingw compiler 4.4.1-tdm-2.


#8 e‍dd   Members   -  Reputation: 2105

Like
0Likes
Like

Posted 06 April 2012 - 01:54 PM

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.

#9 Devil0150   Members   -  Reputation: 153

Like
0Likes
Like

Posted 06 April 2012 - 02:26 PM

I tried compiling from the command line with the example you gave me and it worked.
Yes, that compiler came with Code::Blocks.


#10 e‍dd   Members   -  Reputation: 2105

Like
0Likes
Like

Posted 06 April 2012 - 03:44 PM

Ok, so what command line is Code::Blocks using to compile/link?

#11 Devil0150   Members   -  Reputation: 153

Like
0Likes
Like

Posted 07 April 2012 - 12:48 PM

The compiler and linker for dynamic libs is mingw32-g++.exe
The linker for static libs is ar.exe

Don't know if these are necessary:
debugger: gdb.exe
Resource compiler: windres.exe
make program: make.exe


#12 e‍dd   Members   -  Reputation: 2105

Like
1Likes
Like

Posted 07 April 2012 - 03:17 PM

What are the commands that Code::Blocks is issuing? i.e. can you find the exact executable paths and list the command line parameters that are being given to them?

If you can, try to build a small program yourself in exactly the same way. If that program runs correctly, we'll have to look at something else. If Code::Blocks is running your builds through gdb, it could be the particular build of gdb that's at fault.

Alternatively, can you find and run the executable that Code::Blocks built for you and run it directly from explorer or the command shell?

#13 Devil0150   Members   -  Reputation: 153

Like
0Likes
Like

Posted 08 April 2012 - 02:26 AM

I found what was wrong. In the link libraries list, I had included all the libraries in the MinGW\lib folder.
I am used to doing that, I can't remember why, and I didn't have a problem with it before cause I haven't work on a console project with iostream for a long time.

I removed all the libraries from the link libraries list and it worked fine.Thx


#14 ApochPiQ   Moderators   -  Reputation: 14679

Like
0Likes
Like

Posted 08 April 2012 - 08:22 PM

Please don't mark threads "solved."


Thanks!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS