eclipse - C++ HelloWorld program compiled with MinGW crashes with "Illegal Argument" -


i decided time learned c++, , after struggling 3+ hours trying compiler work, created working program. however, seemingly spontaneously broke when tried refactor project in eclipse cutting , pasting it. program crashes, , windows brings dreaded dialogue "helloworld.exe has stopped working." bit of debugging revealed "cout" considered illegal argument. looked more issue, , i'm suspicious has compiler apparently being 32-bit, have 64-bit system. executable listed in eclipse "helloworld.exe - [x86/le]." (minus period.) program in full below:

#include <iostream>  using namespace std;  int main(){     cout << "hello world!" << endl;     return 0; } 

i've discovered creating new "helloworld" c++ project in eclipse absolutely nothing fix issue, using unmodified code , settings. have suggestions why happen?

edit: debugging information: upon running program:

hello world! program received signal signill, illegal instruction. 0x6fccc3c0 in libstdc++-6!_zst4cout ()     c:\windows\syswow64\libstdc++-6.dll (gdb) bt #0   0x6fccc3c0 in libstdc++-6~_zst4cout ()     c:\windows\syswow64\libstdc++-6.dll #1   0x6fc8908c in libstdc++-6~_zst4cout ()     c:\windows\syswow64\libstdc++-6.dll #2   0x004013be in libstdc++-6~_zst4cout () @ helloworld.cpp:4 (gdb) 

it should noted line 4 of class points cout call.

after looking @ gdb backtrace, problem appears incompatible c++ runtime libstdc++.dll.

this happen if you're installing mingw on existing install. way happen if other third party program needing libstdc++.dll installed dependencies windows\syswow64 found system wide. issue of course, differing versions of libstdc++ aren't compatible each other @ abi level. programs compiled given mingw g++ version needs load corresponding libstdc++.dll came particular mingw install.

open new cmd.exe prompt , set path environment current mingw\bin install directory. example, if mingw install in c:\mingw32-4.7.2:

c:\>set path=c:\mingw32-4.7.2\bin 

then try running helloworld.exe again. if runs completion without crashing problem. in case should remove libstdc++.dll windows\syswow64.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -