0

When I try to build and run a new program in Code::Blocks, the console window pops up blank and I have to click the exit button to stop it. It does this for any new project I have tried including "Hello world". Oddly it works normally for any older projects that I have.

I looked in toolchain executables for both my new projects and the old and everything is identical. It's not a problem with my code because if I copy and paste it into an old project file, it runs as it should.

I'm running Code::Blocks 13.12 on Windows 10.

Thanks.

enorling
  • 1
  • 1
  • 1
  • 2
    Are you running Avast? – NathanOliver Dec 17 '15 at 18:35
  • Yes, I am running Avast. – enorling Dec 17 '15 at 18:50
  • 1
    Turn it off and try again. There have been problems with it. see this: http://stackoverflow.com/questions/33690697/running-my-c-code-gives-me-a-blank-cmd – NathanOliver Dec 17 '15 at 18:51
  • Excluding the directory from avast did the trick, Thank you! – enorling Dec 17 '15 at 19:30
  • This post should have never been closed based on the link provided, where problem is listed as a ***Visual Studios*** related problem: _I'm trying to run some c++ code in Visual Studio 2015._ This post specifically asks a question about a very annoying ***Code::Blocks*** issue. And although _Avast_ in this case was the culprit, there are more commonly occurring reasons why people continue to ask the question: _Why is console appearing when running simple executable in Code::Blocks?_ Even the linked _duplicate_ has a comment asking that answer be generalized for Code::Blocks. it is not. – ryyker Feb 17 '17 at 17:53

2 Answers2

1

This is a bit vague. Here is my idea , go to settings compiler and them press 'reset defaults' then click 'ok' you should have a pop-up with your compiler ussually something like 'GNU/GCC' if not download here http://sourceforge.net/projects/codeblocks/files/Binaries/13.12/Windows/codeblocks-13.12mingw-setup-TDM-GCC-481.exe This works with and second when you are making the project make sure you have a valid location on your pc.

JohnnyOnPc
  • 386
  • 1
  • 5
  • 18
0

Could you test if it works when not in debug? By compiling a release (as an example)? If it works without debug, I suppose it could have something to do with the debugger or the linker.

Check the linker syntax, to be sure it is -Wl,--enable-auto-import You can find those options here;

"Settings" -> "Compiler and debugger..."
"Global compiler settings"
"Linker settings"

Like NathanOlivier said, you should try to add an exclusion for your "\Visual Studio 2015\Projects" directory for Avast. Running my C++ code gives me a blank console (See the solution by Blastfurnace)

Community
  • 1
  • 1
David Gourde
  • 3,709
  • 2
  • 31
  • 65