My problem is that code::blocks error message tells me that it can't find file executable in the search path for gnc gcc
compiler. Although, I don't know what that means. Also I typed out some code:
#include <iostream> using namespace std; int main(void) { cout <<"Hello World" <<endl; return 0; }
I can't build it or run in code::blocks
. What do I need to do?
I went on line but I got some answers that are way over my head. I was able to use code::blocks once before I installed Visual studios express 2013
. Visual studios
didn't work right either. It kept asking me to repair or uninstall every time I tried to open it. So I deleted it along with code::blocks
. Now that I re-installed code::blocks
I still can't get to work right.
This problem with compilers is taking up all my time and I can't practice learning programming because I can't get any compiler to work right. I need some help, please.
;C:\MinGW\bin Click Start and type cmd in the search field, then press Enter. In the window that appears, enter gcc and press the Enter key again. You should get a response gcc: no input files . This means that Windows could find the gcc program, which is what we want.
The problem is solved with simple tricks Try to go Settings->Compiler->Select "GNU gcc" from the drop down menu -> Then press "set as default" button. Close the dialog with OK Close codeblocks and restart it Open codeblocks and try to create a new project.
In the Windows search bar, type 'settings' to open your Windows Settings. Search for Edit environment variables for your account. Choose the Path variable in your User variables and then select Edit. Select New and add the Mingw-w64 destination folder path to the system path.
I'm guessing you've installed Code::Blocks but not installed or set up GCC yet. I'm assuming you're on Windows, based on your comments about Visual Studio; if you're on a different platform, the steps for setting up GCC should be similar but not identical.
First you'll need to download GCC. There are lots and lots of different builds; personally, I use the 64-bit build of TDM-GCC. The setup for this might be a bit more complex than you'd care for, so you can go for the 32-bit version or just grab a preconfigured Code::Blocks/TDM-GCC setup here.
Once your setup is done, go ahead and launch Code::Blocks. You don't need to create a project or write any code yet; we're just here to set stuff up or double-check your setup, depending on how you opted to install GCC.
Go into the Settings
menu, then select Global compiler settings
in the sidebar, and select the Toolchain executables
tab. Make sure the Compiler's installation directory
textbox matches the folder you installed GCC into. For me, this is C:\TDM-GCC-64
. Your path will vary, and this is completely fine; just make sure the path in the textbox is the same as the path you installed to. Pay careful attention to the warning note Code::Blocks shows: this folder must have a bin
subfolder which will contain all the relevant GCC executables. If you look into the folder the textbox shows and there isn't a bin
subfolder there, you probably have the wrong installation folder specified.
Now, in that same Toolchain executables
screen, go through the individual Program Files
boxes one by one and verify that the filenames shown in each are correct. You'll want some variation of the following:
gcc.exe
(mine shows x86_64-w64-mingw32-gcc.exe
)g++.exe
(mine shows x86_64-w64-mingw32-g++.exe
)g++.exe
(mine shows x86_64-w64-mingw32-g++.exe
)gcc-ar.exe
(mine shows x86_64-w64-mingw32-gcc-ar.exe
)GDB/CDB debugger: Default
windres.exe
(mine shows windres.exe
)make.exe
(mine shows mingw32-make.exe
)Again, note that all of these files are in the bin
subfolder of the folder shown in the Compiler installation folder
box - if you can't find these files, you probably have the wrong folder specified. It's okay if the filenames aren't a perfect match, though; different GCC builds might have differently prefixed filenames, as you can see from my setup.
Once you're done with all that, go ahead and click OK
. You can restart Code::Blocks if you'd like, just to confirm the changes will stick even if there's a crash (I've had occasional glitches where Code::Blocks will crash and forget any settings changed since the last launch).
Now, you should be all set. Go ahead and try your little section of code again. You'll want int main(void)
to be int main()
, but everything else looks good. Try building and running it and see what happens. It should run successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With