分类: WINDOWS
2010-03-16 02:19:28
4.4. Microsoft compiler toolchain (Win32 native) | ||
---|---|---|
Chapter 4. Tool Reference |
To compile Wireshark on Windows using the Microsoft C/C++ compiler, you'll need:
C compiler (cl.exe
)
Linker (link.exe
)
Make (nmake.exe
)
C
runtime headers and libraries (e.g. stdio.h,
msvcrt.lib
)
Windows
platform headers and libraries (e.g.
windows.h, WSock32.lib
)
HTML help headers and libraries (htmlhelp.h,
htmlhelp.lib
)
The official Wireshark 1.0.x releases are compiled using Microsoft Visual C++ 6.0. The subsequent releases are compiled using Microsoft Visual C++ 2008 SP1. Using the release compilers is recommended for Wireshark development work. Visual C++ 2008 Express Edition SP1 may be used for the development branch, but it cannot create PortableApps or U3 packages.
However, you might already have a different Microsoft C compiler installed. With the considerations listed below, it should be possible to use it as well:
Compiler Package |
IDE / Debugger? |
Publicly available? |
Platform SDK required? |
config.nmake: MSVC_VARIANT |
set compiler PATH and alike settings with: |
Remarks |
Visual Studio 6.0 |
Yes |
Commercial 1 |
No 2 |
MSVC6 |
Microsoft Visual Studio\VC98\Bin\vcvars32.bat |
- |
Visual Studio .NET (2002) |
Yes |
Commercial 1 |
MSVC2002 |
Microsoft Visual Studio .NET\Vc7\bin\vcvars32.bat |
- | |
Visual Studio .NET 2003 |
Yes |
Commercial 1 |
MSVC2003 |
Microsoft Visual Studio .NET 2003\Vc7\bin\vcvars32.bat |
- | |
Visual Studio 2005 |
Yes |
Commercial |
MSVC2005 |
Microsoft Visual Studio 8\VC\bin\vcvars32.bat |
- | |
Visual C++ 2005 Express Edition |
Yes |
(474MB) |
(420MB) |
MSVC2005EE |
Microsoft Visual Studio 8\VC\bin\vcvars32.bat |
vcredist_x86.exe 3 |
Visual Studio 2008 |
Yes |
Commercial |
No 2 |
- MSVC2008 |
Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat |
- |
Visual C++ 2008 Express Edition SP1 (recommended) |
Yes |
|
No 2 |
MSVC2008EE |
Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat |
vcredist_x86.exe 3 |
.NET Framework SDK version 1.0a |
No |
(104MB) |
(420MB) |
DOTNET10 |
Microsoft.NET\FrameworkSDK\Bin\corvars.bat |
can't build setup 4 |
.NET Framework SDK Version 1.1 5 |
No |
(106MB) |
DOTNET11 |
Microsoft.NET\SDK\v1.1\Bin\sdkvars.bat |
can't build setup 4 | |
.NET Framework 2.0 SDK 5 |
No |
(363MB) |
DOTNET20 |
Microsoft.NET\SDK\v2.0\Bin\sdkvars.bat |
vcredist_x86.exe 3 | |
Windows SDK for Windows Vista and .NET Framework 3.0 Runtime Components |
No |
(1188MB) |
No 2 |
- (not yet implemented!) |
Microsoft SDKs\Windows\v6.0\Bin\SetEnv.Cmd |
vcredist_x86.exe 3 |
1no longer officially available, might still be available through the MSDN subscriptions
2as the Platform SDK is already integrated in the package, you obviously don't need to install it and don't even need to call a separate environment setting batch file for the Platform SDK!
3vcredist_x86.exe
(3MB free download) is required to build
Wireshark-win32-1.2.x.exe
.
The version of vcredist_x86.exe
MUST
match
the version for your compiler.
4
Wireshark-win32-1.2.x.exe
cannot be created with this package, as msvcr*.dll
is not available or not redistributable!
5MSDN remarks that the corresponding .NET runtime is required. It's currently unclear if the runtime needs to be installed for the C compiler to work - or is this only needed to compile / run .NET programs?!?
Note! | |
---|---|
The "Visual C++ Toolkit 2003" should NOT be used to compile Wireshark! |
Please note: The following is not legal advice - ask your preferred lawyer instead! It's the authors view, but this view might be wrong!
The myriad of port projects all seem to believe there are legal issues involved in using newer versions of Visual Studio. This FUD essentially stems from two misconceptions:
Unfortunately, it is believed by many that the Microsoft Visual Studio 2003 EULA explicitly forbids linking with GPL'ed programs. This belief is probably due to an improper interpretation of the , which places redistribution restrictions only on SOURCE CODE SAMPLES which accompany the toolkit.
Other maintainers believe that the GPL itself forbids using Visual Studio 2003, since one of the required support libraries (MSVCR71.DLL) does not ship with the Windows operating system. This is also a wrongful interpretation, and the explicitly addresses this issue.
Similar applies to Visual Studio 2005 and alike.
So in effect it should be perfectly legal to compile Wireshark and distribute / run it if it was compiled with any MSVC version > V6!
The following table gives an overview of the possible Microsoft toolchain variants and their specific C compiler versions "ordered by release date":
Compiler Package |
cl.exe |
_MSC_VER |
CRT DLL |
Visual Studio 6.0 |
6.0 |
1200 |
msvcrt.dll (Version 6) |
Visual Studio .NET (2002) |
7.0 |
1300 |
msvcr70.dll |
.NET Framework SDK version 1.0a | |||
Visual Studio .NET 2003 |
7.10 |
1310 |
msvcr71.dll |
.NET Framework SDK Version 1.1 | |||
Visual Studio 2005 |
8.0 |
1400 |
msvcr80.dll |
Visual C++ 2005 Express Edition | |||
.NET Framework 2.0 SDK | |||
Windows SDK for Windows Vista and .NET Framework 3.0 Runtime Components | |||
Visual Studio 2008 |
9.0 |
1500 |
msvcr90.dll |
Visual Studio 2008 Express Edition |
After correct installation of the toolchain, typing at the command line prompt (cmd.exe):
>
cl
should result in something like:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption...
However, the version string may vary.
nmake is part of the toolchain packages described above.
Instead of using the workspace (.dsw) and projects (.dsp) files, the traditional nmake makefiles are used. This has one main reason: it makes it much easier to maintain changes simultaneously with the GCC toolchain makefile.am files as both file formats are similar. However, as no Visual Studio workspace/project files are available, this makes it hard to use the Visual Studio IDE e.g. for using the integrated debugging feature.
After correct installation, typing at the command line prompt (cmd.exe):
>
nmake
should result in something like:
Microsoft (R) Program Maintenance Utility Version 6.00.9782.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
However, the version string may vary.
Documentation on nmake can be found at
XXX - add info here
Please note: The following is not legal advice - ask your preferred lawyer instead! It's the authors view, but this view might be wrong!
Depending on the Microsoft compiler version you use, some binary files coming from Microsoft might be required to be installed on Windows machine to run Wireshark. On a developer machine, the compiler setup installs these files so they are available - but they might not be available on a user machine!
This is especially true
for the C runtime DLL
(msvcr*.dll), which contains the implementation of ANSI and
alike functions, e.g.: fopen(), malloc(). The DLL is named
like: msvcr
MSVC6 was using
msvcrt.dll, which is already available
on all recent windows systems - no need to redistribute
anything. Starting with MSVC7, it is necessary to ship the C
runtime DLL (msvcr
Note! | |
---|---|
The files to redistribute must be mentioned in the redist.txt file of the compiler package - otherwise it can't be legally redistributed by third parties like us! |
The following MSDN links are recommended for the interested reader:
Redistributables weren't an issue with MSVC 6, as any realistic installer target system (>= Win95) already contains the corresponding msvcrt.dll.
"Visual Studio .NET (2002)" - comes with this dll and it's mentioned in redist.txt.
".NET Framework SDK 1.0" doesn't even come with this dll. XXX - Is this file available with the .NET 1.0 runtime (dotnetfx.exe) - so it could be shipped instead?!? Do we want it that way?
"Visual Studio .NET 2003" comes with this dll and it's mentioned in redist.txt.
".NET Framework SDK 1.1" comes with this dll, but it's NOT mentioned in redist.txt. XXX - Is this file available with the .NET 1.1 runtime (dotnetfx.exe) - so it could be shipped instead ?!? Do we want it that way?
There are three redistribution methods that MSDN mentions for MSVC 8 (see: " "):
"Redistributable Merge Modules" (kind of loadable modules for building msi installers - not suitable for Wireshark's NSIS based installer)
copy the folder content of Microsoft.VC80.CRT to the target directory (e.g. "C:\program files\Wireshark")
vcredist_x86.exe (needs to be executed on the target machine - MSDN recommends this for the 2005 Express Editions)
To save installer size, MSVC2005 uses the content of Microsoft.VC80.CRT (method 2 - this is the smallest package). As MSVC2005EE and DOTNET20 doesn't provide the folder "Microsoft.VC80.CRT" they use method 3. You'll have to download a vcredist_x86.exe from Microsoft that matches your compiler version. The best way to determine this version is to open one of the generated manifest files (e.g. wireshark.exe.manifest) and look for the version of the Microsoft.VC80.CRT entry.
8.0.50608.0, from: "Microsoft Visual C++ 2005" (and probably the Express Edition as well):
8.0.50727.762, from: "Microsoft Visual C++ 2005 Express Edition - ENU Service Pack 1 (KB926748)":
Please report to the developer mailing list, if you find a different version number!
9.0.21022.8, from: "Microsoft Visual C++ 2008 Redistributable Package (x86)":
9.0.30729.17, from: "Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)":
Please report to the developer mailing list, if you find a different version number!
As the corresponding C compiler is preliminary, it's too early to say!
The Windows Platform SDK (PSDK) is a free (as in beer) download and contains platform specific headers and libraries (e.g. windows.h, WSock32.lib, ...). As new Windows features evolve in time, updated PSDK's become available that include new and updated API's.
When you purchase a commercial Visual Studio, it will include a PSDK. The free (as in beer) downloadable C compiler versions (VC++ 2005 Express, .NET Framework, ...) do not contain a PSDK - you'll need to download a PSDK in order to have the required C header files and libraries.
Older Versions of the Platform SDK should also work. However, the command to set the environment settings will be different, try search for SetEnv.* in the SDK directory.
BTW: "Windows SDK" seems to be the new name of the Platform SDK for Vista. The current SDK name is misleading: "Microsoft Windows Software Development Kit for Windows Vista and .NET Framework 3.0 Runtime Components" - translated this means: the Windows SDK for Windows Vista and Platforms (like WinXP) that have the .NET 3.0 runtime installed.
The HTML Help is used to create the User's and Developer's Guide in .chm format and to show the User's Guide as the Wireshark "Online Help".
Both features are currently optional, but might be mandatory in future versions.
This compiler is used to generate a .chm file from a bunch of HTML files - in our case to generate the User's and Developer's Guide in .chm format.
The compiler is only available as the free (as in beer) "HTML Help Workshop" download. If you want to compile the guides yourself, you need to download and install this. If you don't install it into the default directory, you may also have a look at the HHC_DIR setting in the file docbook/Makefile.
The files htmlhelp.c and htmlhelp.lib are required to be able to open .chm files from Wireshark - to show the "online help".
Both files are part of the Platform SDK (standalone PSDK or MSVC since 2002). If you still use MSVC 6, you can get them from the "HTML Help Workshop" mentioned above.
The related settings in config.nmake depend on the MSVC variant you use:
MSVC 6: if the "HTML Help Workshop" is installed, set HHC_DIR to its directory
> MSVC 6: set HHC_DIR to use it (the actual value doesn't matter in this case)
Well, using a good debugger can save you a lot of development time.
The debugger you use must match the C compiler Wireshark was compiled with, otherwise the debugger will simply fail or you will only see a lot of garbage.
You can use the integrated debugger of Visual Studio - only available in some of the toolchain packages.
However, setting up the environment is a bit tricky, as the Win32 build process is using makefiles instead of the .dsp/.dsw files usually used.
XXX - add instructions how to do it.
You could also use the Microsoft Debugging Tools for Windows toolkit, which is a standalone GUI debugger. Although it's not that comfortable compared to debugging with the Visual Studio integrated debugger, it can be helpful if you have to debug on a machine where an integrated debugger is not available.
You can get it free of charge at: http://www.microsoft.com/whdc/devtools/debugging/default.mspx (as links to Microsoft pages change from time to time, search for "Debugging Tools" at their page if this link should be outdated).
4.3. GNU compiler toolchain (UNIX or Win32 Cygwin) | 4.5. bash |