Author Topic: Installation of free Visual Compiler VC2010 and Debugger - Windows 7  (Read 5956 times)

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 190
Hi All,

most posts in the forum about VC compilers with C::B seem to require that you have set up
Visual Studio or VC Express. The only place I found with an alternative was the wiki with a setup
of the VC2010 for 64bit from the WinSDK, which did not fully work for me.
And no one really talks about the debugger?!

I want to use MinGw and VC2010 side by side and I want to debug both. I want to develop 32bit
on VC2010 as well. I want to develop Direct3D11 stuff with CodeBlocks. I want a way to
offline install (thats not possible with VC Express).

Here is how I did achive that in a step by step manner. 

You need: 
Code
 - CB Installation, e.g. Full installer for Windows, e.g. V15.12 or V16.01.
 - Download Windows SDK, 7.1. Make sure you select the *.iso version, about 600MB
 - Download VS2010_SP1 compiler pack, size should be about 130MB
 - Download DirectX SDK (June 2010), about 600MB
 - Symbols (optional, see below)

Assuming Windows7x64, SP1. ( Note: typos!, do not use copy & paste.)
 - CB standard installation
 - Burn ISO on CD or use ISO Image directly with a virtual CD/DVD drive
 - Install Windows SDK, you will need 1.5GB space on C: Max 300MG can be put on another drive
   - select all options in the setup. It will install 32 and 64bit compilers
     Make sure all VC++2010 runtime distributables are uninstalled via the control panel before starting
     the setup. Otherwise you might get a mysterious installation error.
   - Setup fails to install the VC resource compiler for some reason. To fix that just copy
      <WinSDKpath>\bin\rc.exe and rcDll.dll
      to
      c:\ProgramFiles(x86)\Microsoft VS 10.0\VC\bin\*.*
   -Setup also fails to install the 32bit debugger, but its on the CD. Just install manually from
    <CD>\Setup\WinSDKdebuggingTools\dbg_x86.msi
   - You might want to download and install symbols, see below
 - Install CompilerPack SP1, Installer should detect the VC2010 compiler and update that.
 - Install DirectX. Note: that might not be required if you are using newer versions only, 
   as some are included in the SDK. But many program support older versions as well and
   thus require that installation.

This finishes the installation. You now have the windows development libraries and headers in the sdk
directory. The VC++2010 compiler is in the programs(x86) directory (for both 32 and 64 bit), named
there VC10. The VC9 directory is installed, but does not contain a compiler, so no choice here. As this
is the latest SDK für Windows7, newer VC++ compilers require VC Express installation.
The CDB debuggers are in programs(x86) for the 32bit version and Program Files for the 64 bit version.
Each CDB debugger as a GUI version named WinDbg.exe. Should you have any debugger issues in
CodeBlocks, its best to check if you have the same issues there, or if its a C:B setup issue. Working
with those can be a bit complex, though.


C::B setup
You should be aware that the CDB integration is not as good as its gnu counterpart gdb. However
it should be enough for the basics and is far better than no integrated debugger. It will remain
a mystery to me how anyone can seriously consider working with an IDE without debugger...
The Setup will create two new compilers settings, one 32bit and one 64 bit, and two new debugger
profiles.
Code
- In Compiler sertings compiler VS2010 to a "Microsoft WinSDK7.1 commandline VC2010_x86 and _x64 
  version. Then edit each:
    - toolchain.
      C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
      C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 for _x64
    - Additional toolchain (different for _x86 and _x64).
      C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE
      C:\Program Files\Debugging Tools for Windows (x32)
      <your WinSDK7.1 path>\Bin
      C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE
      C:\Program Files\Debugging Tools for Windows (x64)
      <your WinSDK7.1 path>\Bin\x64
    - compiler  path (make sure SDK is first)
    <your WinSDK7.1 path>\Include
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
    - linker (different for _x86 and _x64)
    <your WinSDK7.1 path>\lib
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
    <your WinSDK7.1 path>\Lib\x64
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64
    - RC (might not really be neeed, but does not hurt...)
      <your WinSDK7.1 path>\Include
      C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
    - Toolchain executables
       come back after you created the debugger profiles and set up the right profile here.
- Debugger
- add 2 new Debugger Profiles
Micosoft CDB_x86 WinSDK7.1
Micosoft CDB_x64 WinSDK7.1
- Type to CDB
     - Put the path to each cdb.exe, see notes above.
      Note. if the window remains red but the path is correct, try close and open it again.
   Now Update compiler settings with the right profile

With those you should be able to run a program under VC2010 and debug it. I was able to
run DirectX9 and DirectX11 applications with it under CodeBlocks, which I thought is really cool.

The MS documentation says the CDB 64bit also should be used when running 32bit applications
on a 64bit machine. This does not seem to work in this configuration and does not seem to be
only a problem at my setup. CDB64 just hang up after program start. If you know the reason,
please post it. When using CDB 32bit it worked for me.

I noted that the debuggers were sometimes really slow. Be sure you have full logging OFF.
Watches are partially OK. Also there are a lot of warnings when the OS symbols are missing.
(Note: the CDB is part of the debugger plugin of CodeBlocks. A new alternative plugin has been
started and put up on GitHub. Obfuscated posted that its still looking for a new active maintainer).


Symbols:
The VC2010 in Debug mode writes debuger information into a program database file (*.pdb).
There is one file per program or library. The pdbs ususally have the program name with pgb ending 
of the default name vc100.pdb (for VC2010 compiler )

The windows SDK does not contain Symbols for the OS files. So for better debugging its recommended
to install symbols. The standard setup has a link to the Microsoft symbol server, but required online
contact to the symbol server. For offline use MS provides Symbol packages for each system version,
e.g. for Win7 64bit

 Windows_Win7SP1.7601.17514.101119-1850.AMD64FRE.Symbols.msi,

about 300MB of *.pdb files. Recommended is to get both 32 and 64bit versions as they do not overlap.
They need 1.8GB, at least 500MB on C-drive. Please note that this does not really work if the offline PC
has had any updates or patches after the date the symbol file version covers, so many updated files
would need newer .pdb files.

In C::B the setup does not allow you to set the symbol path or the path to the symbol server. Instead
you use the _NT_SYMBOL_PATH environment variable. A value starting with srv*\\ points to a symbol server.


This got it working for me. Hope it works for others as well and is considered useful.

Cheers,
Tiger




Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Installation of free Visual Compiler VC2010 and Debugger - Windows 7
« Reply #1 on: March 17, 2016, 07:16:07 pm »
I have been using MSVC compilers with C::B for a long time, both MSVC2008, MSVC2010 and now MSVC2013. I didn't read everything you wrote, but I can confirm that using C::B with both free express versions and the paid "professional" ones works just fine for MSVC2010 and MSVC2013.

I have a PDF that describes the setup in some detail, with main focus on MSVC2013 64bit. This way allows switching between MSVC compilers simply by switching to another C::B global variable set, assuming the projects use a generic compiler named "MSVC". However, I can't upload the PDF (600 KB) because it is bigger than the forum limit....




Offline tigerbeard

  • Almost regular
  • **
  • Posts: 190
Re: Installation of free Visual Compiler VC2010 and Debugger - Windows 7
« Reply #2 on: March 18, 2016, 07:01:29 pm »
Thats Interesting. What is the advantage to switch based on C:B globar vars compared to use compiler setting dialog and select a compiler?

Maybe you could post in a link when you have access to an online store.