Integrating Microsoft Visual Toolkit 2003 with Code::Blocks IDE
- 1 Microsoft Visual C++ Toolkit 2003 - Overview
- 2 What does VC Toolkit include, and what does it not?
- 3 Packages needed
- 4 Okay, so let's proceed with installation:
- 5 Setting up the compiler
- 5.1 First run compiler auto-detection
- 5.2 Setting compiler from scratch (missed or failed first run auto-detection)
- 5.3 Setting Platform SDK (these steps applies to .NET SDK and DirectX SDK as well)
- 5.4 Compiling Hints
- 5.5 Problems and Solutions
Microsoft Visual C++ Toolkit 2003 - Overview
Microsoft Visual C++ Toolkit 2003 (or VCToolkit, MVCT) is freely available and free for commercial use minimalistic compiler suite released by Microsoft. It consists of high quality C/C++ optimizing compiler (VC 7.1, which is much better than old VC++ 6.0) and linker, but obviously comes without IDE, thus making management of medium and larger projects nearly impossible. Luckily, it's where Code::Blocks IDE with its multi-compiler integration feature comes in handy! This tutorial will cover process of integrating these two incredible pieces of software - VCToolkit and Code::Blocks IDE.
Note: if you like watching rather than reading, and don't mind downloading 40MB, you can get videos made by guys from Gametutorials.com. They have provided us with some easy step-by-step Code::Blocks tutorials, that will help you successfully set up your first steps with VC Toolkit compiler.. :)
What does VC Toolkit include, and what does it not?
According to readme.txt shipped with package, Microsoft Visual C++ Toolkit 2003 does include:
- Visual C/C++ compiler and linker, same as these shipped with Visual Studio .NET 2003 Professional!
- C Runtime Library and the C++ Standard Library, including the Standard Template Library. These are the same static-link libraries included with Visual Studio.
- Microsoft .NET Framework Common Language Runtime. Visual C++ can optionally build applications that run on the Common Language Runtime (CLR).
- Code samples. The toolkit includes four samples designed to showcase the powerful new features of the 2003 version, including new optimization capabilities, features to improve code-security and robustness, enhanced ISO C++ standards support, and the ability to use the .NET Framework library and target the CLR.
According the same source, MSVT does NOT include:
- Various development tools shipped only with commercial Visual Studio IDE - like debugger, profiler, etc.
- Microsoft Foundation Class (MFC) and Active Template Libraries (ATL).
- Advanced developer tools, including compilers and tools for developing using other languages like Visual Basic and C#.
In order to set up Code::Blocks IDE with Microsoft Visual C++ Toolkit 2003 you need following packages:
- Code::Blocks IDE itself.
- You can grab the latest version of Code::Blocks IDE in download section of Code::Blocks homepage or at project's site at Source Forge. (~3 MB)
- Microsoft Visual C++ Toolkit 2003 compiler suite
- This package contains fully functional Visual C++ 7.1 compiler suite, which is free for commercial use. It contains minimalistic set of tools and C/C++ header and library files required for basic application development. You can download latest release of MVCT from Microsoft's website. (~31.4 MB)
Optional RECOMMENDED packages
Rather sooner than later you will encounter problems with missing libraries, that are not included in MVCT bundle. To save yourself most of the trouble you should install freely available SDK packages available at Microsoft's website. They will greatly enchance functionality offered by VC7.1.
Packages that you should definitely take a look are:
- Platform SDK
- This package provides a whole bunch of useful stuff not only for Visual C++ compiler users, but generally, any Windows developer - it includes extensive headers and libraries, as well as tools (like resource compiler, not included in basic VCToolkit package), documentation and samples.
- There are three ways to obtain Platform SDK:
- Platform SDK in its most compact shape - download tiny (~1.2 MB), compact installer, which will guide you through rest of the installation process (online). You will also decide yourself which components you want to install.
- Platform SDK Full Download (beware, it's HUGE!)
- Complete Platform SDK, with all things you will ever need or not. Huge, self-extracting *.cab installer.
- Platform SDK ISO Install (beware, it's HUGE!)
- Same as above, but you get it as *.img (CD image) file.
- Choose the most convinient way for yourself.
- .NET Framework SDK Version 1.1
- This package provides a lot of stuff useful for .NET development, but also, few crucial libraries that are missing (in their debug & multithreaded version) in regular Platform SDK - for more details check this Code::Blocks FAQ entry. You can download .NET Framework SDK here.
- DirectX SDK
- If you are interested in Graphics programming, you might try to integrate DirectX SDK with your MVCT as well (feel free to update C::B Wiki about your succesful attempts, DirectX setup & "hello DX world" compilation are welcome! :P). You can get DirectX SDK here.
Okay, so let's proceed with installation:
Basically, it doesn't really matter what you install first. The most convinient way, however, is to have compiler suite installed before running Code::Blocks IDE for the first time. In such case, C::B will likely autodetect available compilers during its startup, and set up everything correctly. If you have some of the components already installed, just skip that part.
Installing Microsoft Visual C++ Toolkit 2003
Simply run VCToolkitSetup.exe and installation process will start. Select a path you want to install MVCT to. This tutorial assumes you installed it to:
When installation is done, navigate to the MSVT directory ("C:\VCToolkit2003\") and run vcvars32.bat. It will set up enviromental variables.
Note: Install MSVT to any subfolder, installing it to bare "C:\" or "D:\" (or any drive letter) will likely cause compiler/linker produce very strange compilation errors and well, its general malfunction :)
Note 2: Installing VCToolkit requires .NET Framework. Most likely you already have it. If not, setup will trigger .NET Framework installation and proceed it smoothly on older Windows NT systems (NT & 2000), newer ones (XP and above) already have it. This one will, however, fail if you have Windows 9x/Me. In order to install VCToolkit on these machines you need to install .NET Framework manually, preventing setup from triggering malfunctioning procedure. [TODO: it would be great if someone who actually tried it describe it somewhere here]
Installing Platform SDK
In this tutorial we will follow Platform SDK Web Install. Download (links above) and run PSDK-x86.exe, PSDK-amd64.exe or PSDK-ia64.exe (according your PCs architecture). Select a path you want to install Platform SDK to. We will use
If you select custom installation, you will have to select which components you want to install. I didn't dare to run typical installation, because it presumably downloads & installs everything (= hundreds of megabytes). Selecting components may be a little tricky, most of them are related to various Microsoft technologies, and if you are using any of them in your applications, you should install these features here, otherwise your programs will likely fail to compile and/or link correctly. You can update your Platform SDK installation at any time.
When installation is finished, navigate to the Platform SDK directory ("C:\PlatformSDK\") and run SetEnv.Cmd.
Installing Code::Blocks IDE
Simply run setup file, and select a path where you want it to be installed.
Note: some of the plugins are MinGW specific (GDB plugin, DevPak plugin). If you are not sure whether you might need them some day (you may switch to MinGW or simply decide to use more than one compiler), better install them (they are just few kilobytes anyway) and eventually keep them disabled.
Now you can run the Code::Blocks IDE for the first time, and set up the compiler.
Setting up the compiler
First run compiler auto-detection
If you have already installed MVCT on your machine, Code::Blocks will autodetect it now (screen), as well as all other supported compilers that are present. If more than one compiler is detected, you can set one of them as default one.
After this step, you should have Visual C++ compiler almost fully integrated with Code::Blocks. You only need to inform compiler about your Platform SDK installation and goodies (like resource compiler) it should find there. Now, either go to "Settings->Compiler" (in your C::B IDE) and then jump quickly to #Setting Platform SDK, or read further to know more details and verify your auto-detection results.
Setting compiler from scratch (missed or failed first run auto-detection)
In case you missed first run auto-detection (MVCT was not present at the time) or somehow it failed, you have to set up your compiler manually. Whole procedure is actually common for any supported compiler, and applies to Microsoft Visual C++ Toolkit 2003 perfectly:
Golden Tip : "In order to integrate any supported compiler with Code::Blocks, all you need to do is to correctly specify location of compiler's executables, as well as compiler's (include) and linker's (lib) directories".
Specifying location of compiler's executables
Go to "Settings->Compiler" and make sure that "Microsoft Visual C++ Toolkit 2003" is selected.
Open "Programs" tab - verify whether Compiler's installation directory (the same you installed VCToolkit to, ie: "C:\VCToolkit2003\" ) is set properly - if not - press "Autodetect". If correct path doesn't appear, simply paste the correct one there or navigate to it using dialog available under "..." button.
Note that all specified executables (compiler, linker, resource compiler) must exist either in the "bin" subdirectory of Compiler's installation path (ie: "C:\VCToolkit2003\bin\") or in any other path specified here as "Extra path". (see screen)
Open "Directories" tab and verify if following entries are present:
"Compiler" tab - entries should point to "include" directories:
"Linker" tab - entries should point to "lib" directories:
If not, do not hestitate to add these ones.
Note: If you ever be using any library that is not included in MVCT (like FMOD, Allegro, or any of thousands open source libraries out there), you need either to add appropriate "include" and "libs" paths here too, or copy headers and libs to already specified paths.
Setting Platform SDK (these steps applies to .NET SDK and DirectX SDK as well)
Setting up Platform SDK looks the same as previous step, you just have to add appropriate entries that point to Platform SDK's "include" and "lib" subdirectories respectively.
Being in "Directories" tab just add following entries:
"Resource compiler" tab:
Do not forget to specify extra path for resource compiler executable (it's in Platform SDK's "bin" subdirectory, ie: "C:\PlatformSDK\Bin" ) - you can do this in "Programs" tab (see screen)
That's all - you can compile your applications using free Microsoft Visual C++ Toolkit 2003 with Code::Blocks as your IDE.
-H1: If the project cannot find "lib.exe" or "cvtres.exe" then use the ones in C:\Program Files\Microsoft Platform SDK\Bin\win64. They correctly make lib files for 32-bit windows. So add to the END of Programs->Additional paths under "Compiler Settings":
C:\Program Files\Microsoft Platform SDK\Bin\win64
-H2: If the project you are compiling complains that it cannot find "msvcrt.lib" then download the .NET 1.1 SDK and add to the END of the Directories->Linker tab:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib
Both the VC++ Toolkit 2003 and the platform SDK omit this library.
-H3: Note that the VC++ Toolkit itself does not come with debugging versions of the .lib library files. For these you should also download the .NET 1.1 SDK and add the linker path as in H2 above.
The MS naming convention for some their libraries seems to be e.g.
release version = libc.lib debug version = libcd.lib multithreaded release version = libmt.lib
etc. (not sure about the 'i' or 'p' variants)
The above link statically.
dynamic multithreaded release version (uses a dll) = msvcrt.lib
Problems and Solutions
Resources adding via a '.rc' file to a Windows program are not linked into the program.
- Go to "Settings->Compiler->[select MSVCToolkit]->Other->Advanced options" and make sure that the command line macro for "Link object files to executable" is like this: "$linker /nologo /subsystem:windows $libdirs /out:$exe_output $libs $link_objects $link_resobjects $link_options"