Difference between revisions of "Integrating Microsoft Visual Toolkit 2003 with Code::Blocks IDE"

From Code::Blocks
Line 129: Line 129:
 
===Compiling Hints===
 
===Compiling Hints===
  
If the project cannot find "lib.exe" then use the one in C:\Program Files\Microsoft Platform SDK\Bin\win64.  It correctly makes lib files for 32-bit windows.  So add to the END of Programs->Additional paths under "Compiler Settings":
+
-- If the project cannot find "lib.exe" then use the one in C:\Program Files\Microsoft Platform SDK\Bin\win64.  It correctly makes 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
 
  C:\Program Files\Microsoft Platform SDK\Bin\win64
  
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:
+
-- 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
 
  C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib
  
 
Both the VC++ Toolkit 2003 and the platform SDK omit this library.
 
Both the VC++ Toolkit 2003 and the platform SDK omit this library.
  
If the project you are compiling has a resource (.rc) file then you will need cvtres.exe when using the VC++ Toolkit 2003.  Goto support.microsoft.com, and search the KB for "cvtres1.exe".  Should come up with "FIX: Visual Studio 97 SP3 Installs Incorrect Cvtres.exe" (187280).  Download cvtres1.exe, rename to cvtres.exe and place this in a directory in the path, e.g. C:\PlatformSDK\Bin.
+
-- If the project you are compiling has a resource (.rc) file then you will need cvtres.exe when using the VC++ Toolkit 2003.  Goto support.microsoft.com, and search the KB for "cvtres1.exe".  Should come up with "FIX: Visual Studio 97 SP3 Installs Incorrect Cvtres.exe" (187280).  Download cvtres1.exe, rename to cvtres.exe and place this in a directory in the path, e.g. C:\PlatformSDK\Bin.
  
 
Both the VC++ Toolkit 2003 and the platform SDK omit this utility.
 
Both the VC++ Toolkit 2003 and the platform SDK omit this utility.

Revision as of 20:13, 8 August 2005

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.

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#.


Packages needed

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)
  • 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.
Complete Platform SDK, with all things you will ever need or not. Huge, self-extracting *.cab installer.
Same as above, but you get it as *.img (CD image) file.
Choose the most convinient way for yourself.

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:

C:\VCToolkit2003\

When installation is done, navigate to the MSVT directory ("C:\VCToolkit2003\") and run vcvars32.bat. It will set up enviromental variables.


Note: 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

C:\PlatformSDK\

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)

Specifying location of compiler's and linker's directories

Open "Directories" tab and verify if following entries are present:

"Compiler" tab - entries should point to "include" directories:

C:\VCToolkit2003\include

"Linker" tab - entries should point to "lib" directories:

C:\VCToolkit2003\lib

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

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:

"Compiler" tab:

C:\PlatformSDK\Include

"Linker" tab:

C:\PlatformSDK\Lib

"Resource compiler" tab:

C:\PlatformSDK\Include

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.

Enjoy!

Compiling Hints

-- If the project cannot find "lib.exe" then use the one in C:\Program Files\Microsoft Platform SDK\Bin\win64. It correctly makes 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

-- 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.

-- If the project you are compiling has a resource (.rc) file then you will need cvtres.exe when using the VC++ Toolkit 2003. Goto support.microsoft.com, and search the KB for "cvtres1.exe". Should come up with "FIX: Visual Studio 97 SP3 Installs Incorrect Cvtres.exe" (187280). Download cvtres1.exe, rename to cvtres.exe and place this in a directory in the path, e.g. C:\PlatformSDK\Bin.

Both the VC++ Toolkit 2003 and the platform SDK omit this utility.