Integrating Microsoft Visual C 6 with Code::Blocks IDE
Attaching the compiler framework
You are still using Microsoft Visual C++ version 6 (MSVC6) and want to shift to Code::Blocks? Here are the steps to integrate the (commercial!) Microsoft Visual C++ version 6 compiler into Code::Blocks.
The following steps are required:
- Make a copy of the Microsoft Visual C++ Toolkit 2003 as follows:
- Goto menu "Settings" -> "Compiler and debugger"
- Select the "Microsoft Visual C++ Toolkit 2003", click the "Copy" Button
- Save the copy e.g. under "Microsoft Visual C++ 6"
- Setup the compiler as follows:
- The path setup (tab "Programs") should be done as following:
- The "Compiler's installation directory" should be set to {YOUR_MSVC6}\VC98
- Under "Additional path's" add:
- {YOUR_MSVC6_COMMON}\MSDEV98\Bin
- {YOUR_MSVC6_COMMON}\Tools
- The compiler/linker setup (tab "Directories) should be done as following:
- Under the tab "Compiler" add the following path's:
- {YOUR_MSVC6}\VC98\Include
- {YOUR_MSVC6}\VC98\MFC\Include
- {YOUR_MSVC6}\VC98\ATL\Include
- Under the tab "Linker" add the following path's:
- {YOUR_MSVC6}\VC98\Lib
- {YOUR_MSVC6}\VC98\MFC\Lib
- Under the tab "Resource compiler" add the following path's:
- {YOUR_MSVC6}\VC98\Include
- {YOUR_MSVC6}\VC98\MFC\Include
- {YOUR_MSVC6}\VC98\ATL\Include
- Under the tab "Compiler" add the following path's:
- The path setup (tab "Programs") should be done as following:
That's it.
Working with "legacy" MSVC6 workspaces/projects
Code::Blocks offers the ability to import Visual C++ 6 workspaces and projects. To import a MSVC6 workspace do the following: Menu "Project" -> "Import" -> "MS Visual C++ workspace". Code::Blocks will ask you if it should apply the default compiler or ask for each project which compiler to chose. Choose the second option. Now Code::Blocks will present a compiler selection dialog for each project of the workspace. Choose your newly created compiler ("Microsoft Visual C++ 6") for each project. Usually this should import your workspace just fine.
Now there is some finetuning required:
- Code::Blocks may have imported the include path's for compiler and linker as absolute path's. This you should verify and setup to relative apth's where apropriate.
- Code::Blocks may have imported the libraries to link against with absolute path's. This you should change to just present the libraries name (e.g. just "MyLib" for the "D:\MyPath\MyOtherPath\MyLib.lib" library). For own libraries there maybe an additional linker include path to be setup for the compiler to find this library.
- Code::Blocks usually does not import the "common" MSVC6 libraries you need to link your project against. Thus you will receive linker erros for unresolved symbols. The MSDN will help you to tell which of the "common" library you need to link against. For example: If the linker issues an "unresolved symbol RegCloseKey" a look in the MSDN will reveal that this is part of the "advapi32.lib". Thus just add "advapi32" (without the lib extension) to the libraries to link your project against. This may take a while but if you just start from the first unresolved symbol linking another common library will usually resolve a whole list of unresolved symbols.
Troubleshooting
- For troubleshooting enable the "Full command line" Under menu "Settings" -> "Compiler" -> "Other" tab, "Compiler logging".
- If you get heaps of warnings, even when compiling a simple Hello World application, you might want to try this. (The error "unrecognized commandline option -g, ignored" should be a hint)
- Goto menu "Settings" -> "Compiler and debugger"
- Goto the "Other" tab
- Hit the "Advanced Options..." button
- Click OK (you might want to tick the "don't bug me" box)
- Click the "Compile single file to object file" thingy (if it's not already selected), and, under "Command line macro", replace "$options" with "/nologo /W3 /GX /D "Win32".
- /GX will fix all the warnings
- /D "WIN32" will fix your problems if you have a large codebase, with dozens of "#ifdef WIN32" and the like.
- /W3 you could change ofcourse, to /W1 till /W5, that's all up to you
- /nologo I'm not sure about, I've copied most of this from the commandline MSVC++ 6.0 itself generates.