Sitemap

Setting up C++ on windows

4 min readAug 24, 2023

--

This process is for codeblocks, with mingw compiler, on windows machine.

Download and install codeblocks for your system
Binary releases — Code::Blocks (codeblocks.org)
Get based on your PC, if less than 4gb ram go for 32bit, else go ahead with non-32 bit version.

No compiler will be detected, we have to install compiler (if you downloaded codeblocks-20.03mingw-setup.exe — it will have compiler with it. You can try that too. Both are fine. I prefer installing compiler later of my choice)

downloaded mingw — https://sourceforge.net/projects/mingw/

Its a GUI version, it will install all required files, let it download things for you.

It will ask you what you will require. Based on your requirement, select what to install. You can visit this installation manager again, and add more if required.

minGW installation manager
installed all required files
- mingw developer toolkit
- mingw32 base
- mingw32 gcc ada 6.3.0–1
- mingw32 gcc fortran 6.3.0–1
- mingw32 gcc g++ 6.3.0–1
- mingw32 gcc objc 6.3.0–1
- mys base

Press enter or click to view image in full size

After selecting required ones
Click Installation-> Apply Changes

Press enter or click to view image in full size
Press enter or click to view image in full size

Open CMD, and type few commands

Yes it wont work XD — Need some more efforts

Press enter or click to view image in full size

Go to the folder, where MinGW is installed, enter to bin — open cmd there, then type the following commands, it should work there.

To make it work everywhere in the PC — we need to add this to a global path directory, which ensures its access from any location. And not limited just to where it is present.

Get Vinay Kumar Verma’s stories in your inbox

Join Medium for free to get updates from this writer.

Adding to path => writing number of school principal on notice board.
Instead of going into the school searching for teacher — we can just call the number from notice board — and done.

But yeah, if you uninstall — do remember to remove the number, I mean path from env variables.

Press enter or click to view image in full size

Now have to added path to compilers — gcc, in include, bin, lib just to be sure.

Update in both user variables, and system variables — just to be on safer side.

Save it — Ok — Apply

Open new terminal, and try g++ and gcc commands -> they should be working now. Its working for me atleast. If not, something you did wrong. Add to comments, will solve.

Now to make it visible to codeblocks — we need to give its path — and tell codeblocks to use, our compiler.

Press enter or click to view image in full size

Build and run — it will not work

codeblocks — settings -> compiler -> toolchain executables -> compiler installation directory -> Modify MinGW path

Rest all should be like this (default)
C compiler — gcc.exe
C++ compiler — g++.exe
linker — g++.exe
linker for static — ar.exe
debugger gdb, cdb
resource compiler — windres.exe
make program — mingw32-make.exe

Now build and run — it will show warning

Press enter or click to view image in full size

It means, compiler is ready to work now
Fix the code error — and run again

Congratulations, you have completed your codeblocks and C++ installation.
Few gaps are left for you to fill yourself, I am sure you will be able to follow through the steps.
I was installing on my system Nth time, so this time penned it down along with installation. Its difficult to find all the links for installations, so yeah penned down for myself. You can also refer too. It actually works.

I hope it would be helpful to you, Enjoy your journey of C++ development. All the Best :)

--

--

Vinay Kumar Verma
Vinay Kumar Verma

Written by Vinay Kumar Verma

Sr Computer Vision Engineer | Using AI to Reduce if-else