Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5227229
  • 博文数量: 1696
  • 博客积分: 10870
  • 博客等级: 上将
  • 技术积分: 18357
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-30 15:16
文章分类
文章存档

2017年(1)

2016年(1)

2015年(1)

2013年(1)

2012年(43)

2011年(17)

2010年(828)

2009年(568)

2008年(185)

2007年(51)

分类: WINDOWS

2010-03-16 02:19:28

4.4. Microsoft compiler toolchain (Win32 native)
 Chapter 4. Tool Reference 

4.4. Microsoft compiler toolchain (Win32 native)

To compile Wireshark on Windows using the Microsoft C/C++ compiler, you'll need:

  1. C compiler (cl.exe)

  2. Linker (link.exe)

  3. Make (nmake.exe)

  4. C runtime headers and libraries (e.g. stdio.h, msvcrt.lib)

  5. Windows platform headers and libraries (e.g. windows.h, WSock32.lib)

  6. HTML help headers and libraries (htmlhelp.h, htmlhelp.lib)

4.4.1. Toolchain Package Alternatives

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]Note!

The "Visual C++ Toolkit 2003" should NOT be used to compile Wireshark!

4.4.2. Legal issues with MSVC > V6?

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:

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

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

4.4.3. cl.exe (C Compiler)

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.

4.4.4. nmake.exe (Make)

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

4.4.5. link.exe (Linker)

XXX - add info here

4.4.6. C-Runtime "Redistributable" files

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.dll, an abbreviation for "MicroSoft Visual C Runtime". For Wireshark to work, this DLL must be available on the users machine.

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.dll) together with the application installer somehow, as that DLL is possibly not available on the target system.

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

4.4.6.1. msvcrt.dll - Version 6.0

Redistributables weren't an issue with MSVC 6, as any realistic installer target system (>= Win95) already contains the corresponding msvcrt.dll.

4.4.6.2. msvcr70.dll - Version 7.0 (2002)

"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?

4.4.6.3. msvcr71.dll - Version 7.1 (2003)

"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?

4.4.6.4. msvcr80.dll / vcredist_x86.exe - Version 8.0 (2005)

There are three redistribution methods that MSDN mentions for MSVC 8 (see: " "):

  1. "Redistributable Merge Modules" (kind of loadable modules for building msi installers - not suitable for Wireshark's NSIS based installer)

  2. copy the folder content of Microsoft.VC80.CRT to the target directory (e.g. "C:\program files\Wireshark")

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

4.4.6.5. msvcr90.dll / vcredist_x86.exe - Version 9.0 (2008)

  • 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!

4.4.6.6. Version 10.0 (2010)?

As the corresponding C compiler is preliminary, it's too early to say!

4.4.7. Windows (Platform) SDK

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.

4.4.8. HTML Help

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.

4.4.8.1. HTML Help Compiler (hhc.exe)

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.

4.4.8.2. HTML Help Build Files (htmlhelp.c / htmlhelp.lib)

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)

4.4.9. Debugger

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.

4.4.9.1. Visual Studio integrated debugger

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.

4.4.9.2. Debugging Tools for Windows

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
阅读(1771) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~