VS开发QT

参考下面的步骤:

Qt 4.6.2 虽然新增了LGPL协议,但这也阻碍了我们在VS中使用Qt。因为免费开源的版本只提供了GCC编译好的二进制库,而没有VC编 译好的二进制库,只有商业版本才有VS编译好的针对Windows的DLL,lib等二进制库。

再者,VC编译器比GCC 还是要强劲很多,并且调试器异常强大。Qt Creator虽然很酷,目前还很粗糙。很多人也更为熟悉VS的界面。用VS编译出二进制库:

1. 下载并安装 qt-sdk-win-opensource-2010.02.1.exe,安装到默认的 c:\qt\2010.02.1。它包含了MingGW和 Qt Creator,以及预编译好的二进制文件(用GCC编译的)。你可以直接使用Qt Creator 开始开发工作,不需要任何额外的配置。

2. 将整个目录 c:\qt\2010.02.1 拷贝一份到 c:\qt\4.6.2-vc。我们将会修改目录c:\qt\4.6.2-vc,使用VC++来编译出所需要的库。这两个目录可以同时存在,Qt使用c:\qt\2010.02.1,Visual Studio 使用 c:\qt\4.6.2-vc。

3. 修改 C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\下的 vsvars32.bat,在环境变量PATH中添加Qt的目录,如 c:\qt\4.5.0-vc\qt,在INCLUDE 添 加上c:\qt\4.5.0-vc\qt\include , 在LIB添加 c:\qt\4.5.0-vc\qt\include, 如:

@set PATH=C:\Qt\4.6.2-vc\qt;c:\Program Files\Microsoft Visual Studio 8\Common7\IDE;c:\Program Files\Microsoft Visual Studio 8\VC\BIN;c:\Program Files\Microsoft Visual Studio 8\Common7\Tools;c:\Windows\https://www.360docs.net/doc/2d4062775.html,\Framework\v3.5;c:\Windows\https://www.360docs.net/doc/2d4062775.html,\Framework\v2.0.50727;c:\Program Files\Microsoft Visual Studio 8\VC\VCPackages;%PATH%

@set INCLUDE=C:\Qt\4.6.2-vc\qt\include;c:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;c:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;%INCLUDE%

@set LIB=C:\Qt\4.6.2-vc\qt\lib;c:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;c:\Program Files\Microsoft Visual Studio 8\VC\LIB;%LIB%

打开一个cmd命令行窗口,把这个文件拖过来执行,这样,你打开的cmd就具有上面设置的环境变量了,但是这些变量只针对你当前的cmd,不会更改本机配置,所以,不要关闭cmd窗口,你需要在这个CMD窗口中完成接下来的命令。

(原文是按照第三步来做的,第一次的时候我也是按这一步骤编译,但由于出了后面的问题,便手动在系统环境变量的path中添加C:\Qt\qt-4.3.1\bin,注意,这里应该对应安装目录,其实效果跟上面的是一样的)

4. 执行

c:\> cd c:\qt\4.5.0-vc\qt

c:\qt\4.5.0-vc\qt> configure -platform win32-msvc2005

上面这行命令,你可以按自己的需要修改,但注意一定要指明 -platform 后的参数,指明想要配置成那个版本的VS。这一步要花点时间,大概60分钟。



5. 输入 nmake,回车,开始编译。这一步跟漫长,我的大概编译 了3个小时~~

注意:如果你是Windows 7下,这里多半会失败,因为Win 7 SDK

有Bug,在binary没有resouce区域的时候mt程序是不能把manifest添加到binary中的(参考:https://www.360docs.net/doc/2d4062775.html,/download/8/8/0/8808A472-6450-4723-9C87-977069714B27/ReleaseNotes.Htm),所以我们需要做一些修改才行,

第一步,在CMD下执行如下命令

c:\qt\4.6.2-vc\qt>echo.>hello.rc

c:\qt\4.6.2-vc\qt> rc.exe /r hello.rc

得到 c:\qt\4.6.2-vc\qt\hello.res 资 源文件。

第二步,修改qmake配置文件,使得Makefile的链接命令中会把hello.res一并链接到binary中。修改mkspecs\win32-msvc2005目录下的qmake.conf文件第52行为

QMAKE_LFLAGS = /NOLOGO C:\Qt\4.6.2-vc\qt\hello.res

这样任何link命令都必然会链接hello.res文件。

然后才能输入nmake开始编译。

6. 安装官方的VS插件qt-vs-addin-1.0.0-beta.exe,

7. 启动 Visual Studio,选择菜单“Qt->Qt Options”,在” Qt Verions ”选项卡点击 “Add”,Version Name随便填,例如 “qt4.6.2-vc”,路径则输入 “C:\Qt\4.6.2-vc\qt”。(网上的资料有 说要建立环境变量QTDIR= C:\Qt\4.6.2-vc\qt,我个人认为是不必要的)。

8. 现在你的Visual Studio 完全具备了Qt的所有功能,新建一个Qt 工程编译运行试一试!

(编译好后,在VS下点击Debug-Debug without debuggine可以看见程序运行的效果,不过

如果直接到debug目录下双击这个exe文件,会提示找不到QtCore4d.dll,这时你需要把C:\Qt\4.5.0-vc\qt\bin加入到PATH环境变量,这目录下还有QtCore4.dll,都是上面编译出来的)。

不过你现在的环境是集成了LGPL版Qt的VS,跟商业版的还是有点不 同。例如Qt Desiner(资源设计器)不是嵌入到VS得,需要通过菜单“Qt->Launch Desiner”来执行(商业版直接双击.ui文件就会启动Qt Desiner)。不过这无关紧要,只是多点几下鼠标而已。

点击“Qt->Launch Linguist”可以启动Qt Linguist,它是一款本地化工具,也十分有用。

接着,遇到了如下问题:

正在创建库 ..\..\..\..\lib\QtWebKitd4.lib 和对象 ..\..\..\..\lib\QtWebKitd4.e

xp

QNetworkReplyHandler.obj : error LNK2001: 无法解析的外部符号 "public: virtual st

ruct QMetaObject const * __thiscall WebCore::FormDataIODevice::metaObject(void)c

onst " ()

QNetworkReplyHandler.obj : error LNK2001: 无法解析的外部符号 "public: virtual vo

id * __thiscall WebCore::FormDataIODevice::qt_metacast(char const *)" (?qt_metac

)

QNetworkReplyHandler.obj : error LNK2001: 无法解析的外部符号 "public: virtual in

t __thiscall WebCore::FormDataIODevice::qt_metacall(enum QMetaObject::Call,int,v

oid * *)" (

@Z)

QNetworkReplyHandler.obj : error LNK2001: 无法解析的外部符号 "public: virtual st

ruct QMetaObject const * __thiscall WebCore::QNetworkReplyHandler::metaObject(vo

id)const " ()

QNetworkReplyHandler.obj : error LNK2001: 无法解析的外部符号 "public: vi

rtual vo

id * __thiscall WebCore::QNetworkReplyHandler::qt_metacast(char const *)" (?qt_m

)

QNetworkReplyHandler.obj : error LNK2001: 无法解析的外部符号 "public: virtual in

t __thiscall WebCore::QNetworkReplyHandler::qt_metacall(enum QMetaObject::Call,i

nt,void * *)" (

@@HPAPAX@Z)

FrameLoaderClientQt.obj : error LNK2019: 无法解析的外部符号 "protected: void __t

hiscall QWebPage::unsupportedContent(class QNetworkReply *)" (?unsupportedConten

),该符号在函数 "public: virtual void __this

call WebCore::FrameLoaderClientQt::download(class WebCore::ResourceHandle *,stru

ct WebCore::ResourceRequest const &,struct WebCore::ResourceRequest const &,clas

s WebCore::ResourceResponse const &)" (

) 中被引用

FrameLoaderClientQt.obj : error LNK2019: 无法解析的外部符号 "protected: void __t

hiscall QWebPage::downloadRequested(class QNetworkRequest const &)" (?downloadRe

),该符号在函数 "public: virtual voi

d __thiscall WebCore::FrameLoaderClientQt::startDownload(struct WebCore::Resourc

eRequest const &)" (

) 中被引用

..\..\..\..\lib\QtWebKitd4.dll : fatal error LNK1120: 8 个无法解析的外部命令

NMAKE : fatal error U1077: “F:\softInstall\vs2005\VC\BIN\link.EXE”: 返回代码“

0x460”

Stop.

NMAKE : fatal error U1077: “F:\softInstall\vs2005\VC\BIN\nmake.exe”: 返回代码

“0x2”

Stop.

NMAKE : fatal error U1077: “cd”: 返回代码“0x2”

听说百度不到答案,那就google一下,是让删除QT目录下的mocinclude.tmp文件,大致路径如下:src/3rdparty/webkit/WebCore/tmp/moc/{debug,release}_shared/mocinclude.tmp,再nmake一次就ok了

=============================================================================================
Release Notes for Windows? Software Development Kit (SDK) for Windows 7 and .NET Framework 3.5 Service Pack 1: Beta


--------------------------------------------------------------------------------

License Agreement
Supported Compiler, Platforms, and Related Software
Installing, Uninstalling, and Using the Windows SDK
Known Issues
Windows SDK Product Support and Feedback

1. Welcome
Welcome to the beta edition of the Microsoft Windows Software Development Kit (SDK) for Windows 7 and .NET Framework 3.5 Service Pack 1.

The Windows SDK contains a set of tools, code samples, documentation, compilers, headers, and libraries that developers can use to create applications that run on Microsoft Windows. You can use the Windows SDK to write applications using the native (Win32/COM) or managed (.NET Framework) programming model.

For access to additional resources and information, such as downloads, forum posts, and the Windows SDK team blog, go to the Windows SDK Developer Center.

1.1 Recommended Tools and Downloads
This release of the Windows SDK does not include a .NET Framework Redistributable Package. Windows 7 Beta includes .NET Framework 3.

5 SP1. Windows Vista and Windows Server 2008 include .NET Framework 3.0.

Users running Windows Server 2003 and Windows XP must install the .NET Framework 3.0 or 3.5 SP1 to run and develop .NET Framework applications. Some samples and tools included in the Windows SDK also require you to install .NET Framework 3.5 SP1.

Along with content that ships in the Windows SDK, Microsoft offers additional free developer tools and resources that you might find helpful, including:

· Debugging Tools for Windows can be used to debug drivers, applications, and services on systems running Windows NT 4.0, Windows 2000, Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008 as well as for debugging the operating system itself. Versions of the Debugging Tools for Windows package are available for 32-bit x86, native Intel Itanium, and native x64 platforms.

· LUA Buglight? is a tool to help both developers and IT professionals (sysadmins) identify the specific causes of admin-permissions issues (LUA bugs) in desktop applications running on Windows XP, Windows Server 2003, or Windows Vista. Once the specific causes have been identified, the bugs can more easily be resolved by fixing the app's source code, or by making configuration changes, allowing the app to work correctly for non-admin users.

· Microsoft .NET Framework 3.0 is Microsoft's managed code programming model building applications on Windows clients, servers, and mobile or embedded devices. It combines the power of the .NET Framework 2.0 with four new technologies: Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), Windows Workflow Foundation (WF), and Windows CardSpace (WCS, formerly InfoCard). The .NET Framework 3.0 ships with Windows Vista and Windows Server 2008.

· Microsoft .NET Framework 3.5 SP1 is the latest update of the .NET Framework, and contains many new features that are compatible with both .NET Framework 2.0 and .NET Framework 3.0. The .NET Framework 3.5 SP1 includes several fixes for .NET Framework 2.0 3.0, and 3.5.

· Microsoft Visual Studio Express is a set of free, lightweight and easy-to-use tools for the hobbyist, novice, and student developer.

· Microsoft Windows PowerShell? command-line shell and scripting language helps IT Professionals achieve greater productivity. Using a new admin-focused scripting language, more than 130 standard command-line tools, and consistent syntax and utilities, Windows PowerShell allows IT professionals to more easily control system administration and accelerate automation. More information on Windows PowerShell is available from the PowerShell Team Blog and the Windows PowerShell Technology Center.

· Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation) provides developers with support for building workflow-enabled applications using Windows Workflow Foundation.

· Windows Server 2008 Developer Center is the of

ficial site about development and management of applications on the Windows Server 2008 platform. The Developer Center includes product information, news, tools, and code samples.

· Windows SDK Developer Center is the official site about development using the Windows SDK and provides information about the SDKs and links to the Windows SDK Blog, Forum, online release notes and other resources.


--------------------------------------------------------------------------------

2. License Agreement
The contents included in the Windows SDK are licensed to you, the end user. Your use of the SDK is subject to the terms of an End User License Agreement (EULA) accompanying the SDK and located in the \License subdirectory. You must read and accept the terms of the EULA before you access or use the SDK. If you do not agree to the terms of the EULA, you are not authorized to use the SDK.


--------------------------------------------------------------------------------

3. Supported Compiler, Platforms, and Related Software
This release of the Windows SDK supports Microsoft Visual Studio 2005 SP1, Microsoft Visual Studio 2008 SP1, and the Microsoft Visual Studio 2008 Express Editions. Express Editions of Visual Studio are available to download from the Visual Studio Express site free of charge.

This release of the Windows SDK supports x86, x64, and IA64 platform architectures for building and running applications on Windows XP SP3, Windows Server 2003 R2, Windows Vista, Windows Server 2008, and Window 7 Beta.


--------------------------------------------------------------------------------

4. Installing, Uninstalling, and Using the Windows SDK
To optimize your Windows SDK setup experience, we strongly recommend that you install the latest updates and patches from Microsoft Update before you begin installing the Windows SDK.

4.1 Installation and Related Content
We recommend that the Windows SDK be installed on a clean computer or completely uninstall any pre-releases of the .NET Framework, the Platform SDK, the Windows SDK and their dependencies before installing this release. These older pre-release components might interfere with this release, causing setup to fail or break functionality.

You might see more than one Windows SDK product listed in the Upgrade Options screen during SDK installation. See Section 4.2 for information on uninstalling SDK components.

These release notes use to refer to the installation folder for the Windows SDK. By default, this folder is C:\Program Files\Microsoft SDKs\Windows\v7.0.

4.1.1 Windows SDK Disk Space Requirements
The complete DVD ISO installation of the Windows SDK requires 1.4 GB or more disk space to install successfully. Please verify that the computer you are installing to has at least the minimum required disk space before beginning setup. If the minimum required disk space is not available, setup will return a fatal error.

4.1.2

How to Install the Windows SDK
This version of the Windows SDK is available as a DVD ISO image. To install it:

1. Burn the ISO to DVD media or mount it on a virtual drive. From that ISO, double-click setup.exe to begin the SDK setup

2. Follow the instructions in the Windows SDK Setup wizard

Note: If you are installing the SDK to a custom location, the Microsoft Document Explorer and the ATL/MFC runtime will not be installed by the Windows SDK. See section 5.2.2 for more information on this issue.

4.1.3 Windows SDK Start Menu Shortcuts
Access the Windows SDK shortcuts through the Start menu (Start, All Programs, Microsoft Windows SDK). The Start menu folder contains shortcuts to:

· The SDK build environment command window

· Windows SDK Release Notes

· Windows SDK documentation

· Samples Reference

· Tools

· Windows SDK Configuration Tool (located under Visual Studio Registration)

4.1.4 Optional Related Content
If you intend to use .NET Framework components, install .NET Framework 3.5 SP1 from the Microsoft Download Center.

If you intend to use Microsoft Visual Studio 2005, install Microsoft Visual Studio 2005 SP1 and Visual Studio 2005 Extensions for .NET Framework 3.0 from the Microsoft Download Center.

Note: If you intend to use Visual Studio 2005 to develop .NET Framework applications, you must install the Windows SDK before installing the Visual Studio 2005 Extensions for .NET Framework 3.0.

If you intend to use Microsoft Visual Studio 2008, install Visual Studio 2008 SP1 from the Microsoft Download Center.

Note: Visual Studio 2008 Extensions for .NET Framework 3.0 are included with Visual Studio 2008.

4.2 Uninstalling
Several applications need to be uninstalled separately from Add/Remove Programs (Programs and Features on Windows Vista or later) in order to remove all Windows SDK components:

· Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1: Beta

· Microsoft FxCop 1.35

· Microsoft Document Explorer

· Microsoft Visual C++ Compilers 2008

You might have installed some of these applications with another product besides the SDK. Removing those applications will make those applications unavailable for other applications that might use them. For example, the Microsoft Visual Studio offline documentation has a dependency on Microsoft Document Explorer.

4.3 Win32 C++ Development with the Windows SDK and Microsoft Visual Studio
In order to utilize Windows SDK headers, libraries, and tools within Microsoft Visual Studio, the SDK-provided Windows SDK Configuration Tool must be run. The Windows SDK Configuration Tool must be run for each user on Windows Vista or later. You can build Win32 applications right out of the box with the Vista SDK components that are embedded in Visual Studio 2008 (Windows headers and librarie

s, tools and reference assemblies). You can switch to the more recent components that ship with the Windows SDK for Windows 7 by using the Windows SDK Configuration Tool. If you install the SDK after you installed VS, you are ready to develop with the headers, libraries and tools in the SDK for Windows SDK. If you installed the Windows 7 SDK before you install Visual Studio, you will need to use the SDK Configuration Tool to set Visual Studio directories back to the Windows 7 SDK content. To run the Windows SDK Configuration Tool, go to Start > All Programs > Microsoft Windows SDK v7.0 > Visual Studio Registration > Windows SDK Configuration Tool (on Windows Vista or later, right-click and select Run as Administrator).

4.4 Building Samples
When building Samples, do so in a directory outside c:\program files to which you have write access. The SDK build environment supports building samples from makefiles, Visual Studio project files or Visual Studio solution files. To build from the command line:

1. Copy the sample to a working folder not under c:\program files. Copying to a location other than c:\program files makes it possible to maintain a pristine copy of the SDK samples and avoid issues when writing to files and directories located under c:\program files.

2. Open the Windows SDK CMD shell (Start > All Programs > Microsoft Windows SDK v7.0, CMD Shell).

3. Build the sample from the command line as follows:

· Build a makefile by typing nmake

· Build a .csproj file by typing msbuild *.csproj /p:platform=[ win32 | X64 | IA64]

· Build a .vbproj file by typing msbuild *.vbproj /p:platform=[ win32 | X64 | IA64]

· Build a .sln file by typing msbuild *.sln /p:platform=[ win32 | X64 | IA64]

· Build a .vcproj by typing vcbuild *.vcproj /platform=[ win32 | X64 | IA64 ]

When building with MSBUILD, you should specify a target platform. If a project is configured to build for several different platform types and if you don't specify which platform you wish to build for, the first platform listed in the solution or project file will be built. Configurations are listed in alphabetical order by Visual Studio, so ‘Itanium’ may be the first configuration listed.

If you want to build an application configured for an X86 machine, specify ‘win32’:

msbuild mysample.vbproj /p:platform=win32

If you want to build an application configured for an X64 machine, specify ‘X64’:

msbuild mysample.vbproj /p:platform=X64

4.4.1 Building .NET Framework Samples
Samples demonstrating .NET Framework 3.0 and 3.5 SP1 can be found individually in the SDK documentation. Each sample has its own description page. From each sample page, you can view the source files for those samples as well as individually download all the files of that sample to a chosen location. The .NET Framework samples can be accessed in bulk by directly opening the sample

.zip files located in \Samples.

4.4.2 Setting Build Environment Switches
To set the build environment, use the setenv.cmd tool within a debug cmd shell by following the steps below..

1. Launch the Windows SDK build environment. From the Start menu, click on All Programs > Microsoft Windows SDK v7.0 > CMD Shell.

2. Set the build environment. At the prompt, type:
"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\setenv.cmd" [/target]

The list of available targets is shown below.

Usage: "Setenv [/Debug | /Release][/x86 | /x64 | /ia64][/vista | /xp | /2003 | / 2008 /win7 ] [-h or /?]"
/Debug - Create a Debug configuration build environment
/Release - Create a Release configuration build environment
/x86 - Create 32-bit x86 applications
/x64 - Create 64-bit x64 applications
/ia64 - Create 64-bit IA64 applications
/vista - Windows Vista applications
/xp - Create Windows XP SP2 applications
/2003 - Create Windows Server 2003 applications
/2008 - Create Windows Server 2008 or Windows Vista SP1 applications
/win7 - Create Windows 7 applications

4.5 File System Layout
By default, the Windows SDK is installed to your local disk in the locations below. The default installation path for most components of this SDK is C:\Program Files\Microsoft SDKs\Windows\v7.0.

The default installation path for the Visual C++ compilers is a different location. On an x86 computer, the default installation path of the Visual C++ compilers is c:\Program Files\Microsoft Visual Studio 9.0\VC. On an x64 or IA64 computer, the default installation path of the Visual C++ compilers is c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC.

Directory
Contents

\Bin
Windows SDK tools

\Help
Windows SDK documentation

\Include
Windows SDK headers

\Lib
Import libraries and TLB files

\License
Windows SDK license information

\No Redist
Non-redistributable files

\Redist
Redistributable files

\Samples
Windows SDK samples

\Setup
Setup files



--------------------------------------------------------------------------------

5. Known Issues
This release of the Windows SDK has the following known issues, categorized by type:

Build Environment
Documentation
SDK Tools and Compilers
Samples

5.1 Build Environment
5.1.1 MSBuild May Report a Dependency on the Microsoft .NET Framework SDK 2.0
The Windows SDK does not set the HKLM\Software\Microsoft\.NETFramework\sdkInstall Rootv2.0 registry key to a string value containing the root directory of the Windows SDK installation. Some MSBuild tasks might expect this registry key to be set. If you already have .NET Framework SDK 2.0 or Microsoft Visual Studio 2005, this key will be set, and you should not encounter a problem. However, if you install the Windows SDK without either the .NET Framework SDK or Microsoft Visual Studio 2005, you mi

ght receive an error message from MSBuild tasks with a dependency on this key. To workaround this issue set the string value of this key to the root directory of the Windows SDK installation. By default, this directory is C:\Program Files\Microsoft SDKs\Windows\v7.0

Additionally, in order to use AL.exe, the ALToolPath parameter must be set and passed to msbuild (see more in section 5.4.11). For the default install location, you can use the following command:

On an X86 computer:

msbuild /p:ALToolPath="C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin

On an X64 or IA64 computer:

msbuild /p:ALToolPath="C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\X64

5.1.2 SDK Build Environment may Fail on X86 XP with VS2005
If your usage scenario matches the one listed below, you will be unable to build in the Windows SDK command line build environment. If you type cl.exe in the SDK command window and press Enter, you will see this error:

This application has failed to start because mspdb80.dll was not found. Re-installing the application may fix this problem.

Computer setup required to repro issue:

1. Windows XP on x86 machine (which has version 5.1.2600.2180 of REG.exe)

2. Visual Studio 2005 installed, but Visual Studio 2008 is NOT installed

Cause: When the SDK build environment window is launched, the SDK file SetEnv.cmd launches Reg.exe. Reg.exe generates standard output when a valid KeyPath is specified and also generates error output when invalid Value is specified. In this scenario, the KeyPath is valid but the value doesn’t exist. For more information, see the Windows SDK blog post on this issue.

Workaround: follow these instructions to manually edit SetEnv.cmd to remove the second call to REG:

1. Open C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd in Notepad or another editor

2. For this line:
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "%VSRegKeyPath%" /v 9.0') DO SET VSRoot=%%B

Either comment out using the REM command (like this):
REM FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "%VSRegKeyPath%" /v 9.0') DO SET VSRoot=%%B

OR delete the line completely.

3. Save SetEnv.cmd

4. Restart the Windows SDK command prompt

5.1.3 Microsoft Visual Studio 2005 or 2008 is Required for .NET Compact Framework Development
The SDK provides documentation and sample code that targets .NET Compact Framework. However, actual development of .NET Compact Framework applications requires Microsoft Visual Studio 2005 or Visual Studio 2008. When building a sample that depends on .NET Compact Framework, you might see this error:

C:\Sample\Foo.csproj(57,11): error MSB4019: The imported project "C:\Windows\https://www.360docs.net/doc/2d4062775.html,\Framework64\v2.0.50727\https://www.360docs.net/doc/2d4062775.html,pactFramework.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

To workaround this issue, install either Microsof

t Visual Studio 2005 or Microsoft Visual Studio 2008, or download and install the .NET Framework 2.0 SDK.

5.1.4 Running a Partial Installation of the Windows SDK Might Change File Link Paths to Point to Nonexistent Files
If you have Microsoft Visual Studio 2008 installed and then install the Windows SDK, an important registry key is changed. This key points to the SDK tools as well as to Windows Headers and Libraries. However, if you run a custom installation of the Windows SDK that does not include either tools or Headers and Libraries, the link to those files will be broken, and your projects will fail to compile with an error like this one:

LINK : fatal error LNK1104: cannot open file 'kernel32.lib'

To fix this issue, either repair Microsoft Visual Studio 2008 to restore it to its original state or install the tools, headers and libraries from the SDK.

5.2 Documentation
5.2.1 Documentation on the Windows Vista Game Explorer is not Included in the Windows SDK
Game Explorer provides an easy, customizable way to present your game to users of Windows Vista. Documentation on using Game Explorer is not included with the Windows SDK. To view this content, visit the MSDN Online Library.

5.2.2 Installing the SDK to a Custom Location Results in Unreadable Documentation and Some Tools Do Not Work
When the Windows SDK is installed to a custom location, the Microsoft Documentation Explorer and the ATL/MFC runtime are not installed by the Windows SDK. These components may already have been installed by other applications, such as Visual Studio or MSDN. If these items have not been installed previously, then documentation will not open and some tools, such as guidgen.exe, will not run.

To workaround this issue:

1. Navigate to \Program Files\Microsoft SDKs\Windows\v7.0\Setup\sfx

2. Double-click on dexplore.exe and vcredist.exe to install Microsoft Document Explorer and the ATL/MFC runtime.

5.3 SDK Tools and Compilers
5.3.1 Some Tools Are Not Included with this Release of the Windows SDK
The following tools are not included with this release of the Windows SDK. These tools had been in the Windows SDK Vista Update:

· caspol.exe

· depends.exe (the Dependency Walker tool can be downloaded from https://www.360docs.net/doc/2d4062775.html,)

· installutil.exe

· msdis150.dll

· regasm.exe

· tracelog.exe

5.3.2 CAPICOM.dll Removed from this Release
CAPICOM.dll has been removed from the Windows SDK. It should be considered a deprecated component. You can find information on alternatives to using CAPICOM here - https://www.360docs.net/doc/2d4062775.html,/en-us/library/cc778518(VS.85).aspx. If you need to use CAPICOM.dll, you can download it separately from https://www.360docs.net/doc/2d4062775.html,/downloads/details.aspx?FamilyID=860EE43A-A843-462F-ABB5-FF88EA5896F6

5.3.3 New Tools Added in this Release
The f

ollowing tools have been added since the M3 release of the Windows SDK:

· Wsutil.exe

· WsTraceDump.exe

· IntentCL.exe

· XpsAnalyzer.exe

· VirtualLightSensor.exe

· Windows Troubleshooting Toolkit

· FileFormatVerifier.exe

5.3.4 Some Tools Require .NET Framework 3.5 SP1
The following tools require .NET Framework 3.5 SP1, which does not ship with the Windows SDK:

· sqlmetal.exe

· wsatui.dll

· aspnet_merge.exe

· SvcConfigEditor.exe

· xsltc.exe

5.3.5 The Command-Lne Environment for the Windows SDK Configuration Tool Supports Only Visual Studio 2008
The command-line environment for The Windows SDK Version Selection tool supports only Visual Studio 2008. It does not support earlier versions of Visual Studio. See the Windows SDK Blog post about the Windows SDK Configuration Tool for more information about the tool and this issue.

5.3.6 Problem Running mt.exe on Windows 7 Beta
The use of mt.exe to add a manifest resource to a PE image file (.EXE, .DLL, etc.) that does not already contain a resource (.rsrc) section in it may fail on Windows 7 Beta. The problem does not occur on Windows XP, Windows Vista, and Windows Server 2008, nor does it occur on Windows 7 Beta when manipulating PE image files that already contain a resource section.

Workarounds:

1. Use mt.exe on Windows XP, Windows Vista or Windows Server 2008 instead of Windows 7 Beta, or

2. If using Windows 7 Beta, use an external manifest file or ensure the PE image has a non-zero length resource section.

a. External Manifest File:
For .EXE files, the manifest need not be embedded as a resource. Rather, it may simply be placed next to the .EXE. I.e., for ‘hello.exe’, the manifest ‘hello.exe.manifest’, when placed next to it, has the same effect as if the manifest were embedded as a resource. This is true only for .EXE files.

b. Create a Non-Zero-Length Empty Resource Section:
If it is imperative that mt.exe later be used to embed a manifest, and the PE image file in question cannot otherwise be guaranteed to have a resource section, then an empty resource script may be used. Despite that the script is empty, the resultant resource section will not be zero-length, and mt.exe can then be used. For example:

i. cl.exe /c hello.c

ii. echo. > hello.rc

iii. rc.exe /r hello.rc

iv. link.exe /out:hello.exe hello.obj hello.res

v. mt.exe -outputresource:hello.exe;1 -manifest: hello.exe.manifest

vi. (the file hello.exe now exists with hello.exe.manifest embedded)

5.4 Samples
5.4.1 Som

e C++ Samples Require Upgrade Prior to Building
To build the samples in the SDK build environment or in Microsoft Visual Studio 2008, you must upgrade many of the Win32 samples project files. The compilers in the SDK are Visual C++ v9.0 SP1, the same compilers that ship in Microsoft Visual Studio 2008 SP1. Many of the sample project files in the SDK are written for VC 8.0 compilers, the compilers that ship in Microsoft Visual Studio 2005. Samples with version 8.0 project files can be built in Microsoft Visual Studio 2005 but must be upgraded before being built in the Windows SDK build environment or in the Visual Studio 2008 or later build environments. When building a project file in the SDK Build environment, you might receive this error:

GramEvcbuild.exe : error VCBLD0010: Project 'foo.vcproj' requires upgrade.

Use 'vcbuild /upgrade' or 'devenv /upgrade' to upgrade the project.

To workaround this issue, follow the prompt in the command window and type vcbuild /upgrade or devenv /upgrade to upgrade the project.

The .NET Framework (managed) sample vcproject files cannot be upgraded using the workaround above. These must be upgraded using vcbuild /upgrade /overrideRefVer "SampleName.vcproj" because upgrade /overriderefver indicates that it will use .NET Framework 3.5.

5.4.2 Some C++ Samples will not Build in Visual Studio 2005
Some of the samples in the SDK contain v9.0 project files, which will not build in Visual Studio 2005. You cannot downgrade the project files to a lower version. To workaround this issue, install Visual Studio 2008 (Express or Retail SKU) or build the sample in the Windows SDK command line build environment.

5.4.3 Some Samples have External Dependencies
Some samples included with the Windows SDK have dependencies on components outside the Windows SDK.

5.4.3.1 ATL/MFC Dependency
Some samples require the ATL and/or MFC headers, libraries, or runtime, which are included with Visual C++ (non-Express editions). When building a sample that depends on ATL/MFC without Visual Studio installed on your computer, you might see an error similar to this:

fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory

To workaround this issue, install a non-Express version of Microsoft Visual Studio 2005 or Visual Studio 2008.

5.4.3.2 Windows Media Player Dependency
The SchemaReader sample requires Windows Media Player 11 or later to be installed.

5.4.3.3 Microsoft Management Console 3.0 Dependency
The samples in the \Samples\SysMgmt\MMC3.0 directory require Microsoft Management Console 3.0 or later to be installed.

5.4.3.4 DirectX SDK Dependency
Some samples require the DirectX SDK (refer to the sample's readme for additional information).

5.4.3.5 msime.h Dependency
Some samples fail to build because the file msime.h is not found. Msime.h is not shipped with the Windows SDK. Msime

.h is for use by developers when customizing applications for the 2007 Microsoft Office System.

The affected samples are:

· winui\Input\tsf\TSFApps\ImmPad-Interim

· winui\Input\tsf\TSFApps\ImmPad-Level3-Step3

· winui\Input\tsf\TSFApps\TsfPad-Hybrid

To workaround this issue, download msime.h from the Microsoft Download Center and copy to the Windows SDK \Include directory.

5.4.4 Some Samples Require Microsoft Visual Studio 2005 and will not Build with Microsoft Visual Studio 2008
A few unmanaged samples rely on mspbase.h, mtyp.h, or mfc80ud.lib. These files are included with Microsoft Visual Studio 2005 and do not ship with Microsoft Visual Studio 2008.

1. mspbase.h

a. netds\Tapi\Tapi3\Cpp\Msp\MSPBase

b. netds\Tapi\Tapi3\Cpp\Msp\Sample

c. netds\Tapi\Tapi3\Cpp\pluggable

2. mtype.h

a. netds\Tapi\Tapi3\Cpp\tapirecv

b. netds\Tapi\Tapi3\Cpp\tapisend

3. mfc80ud.lib

a. Sysmgmt\Wmi\VC\AdvClient

5.4.5 Some C++ Samples with Visual C++ 2005 Project Files do not have Configurations for x64
When building a C++ sample that does not have support for x64 on an x64 computer, you might see the following error message:

fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'

To workaround this issue, perform one of the following actions:

1. Build the sample targeting x86 by using this code:

vcbuild *.vcproj /platform=win32

2. Add x64 support by doing the following:

a. Load the sample in Microsoft Visual Studio (C++).

b. Update the Configuration Manager under Project | Properties.

For detailed instructions, see the Windows SDK Blog post "How to add 64-bit support to vcproj files."

Note: if you do not install libraries for all CPU architectures during SDK setup, some samples with Visual C++ project files might fail to build with this error for all configurations in the project file:

Fatal error LNK1181: cannot open input file

For example, if a sample has an x86 configuration and x86 libraries were not installed (these libraries are installed by default when installing the SDK on all platforms), the sample will fail to compile.

5.4.6 Visual J# Samples Require VJ++ (Visual Studio)
J# samples will not build using the Windows SDK because there is no appropriate build environment. This edition of the Windows SDK does not support building J# applications. To workaround this issue, install Visual Studio (VJ++) 2005.

5.4.7 Setupvroot.bat Setup Script for WCF Samples Fails on Windows Vista if the NetMsmqActivator Service is Enabled and Message Queuing (MSMQ) is not Installed
The Windows Communication Foundation samples setup script Setupvroot.bat does not work on Windows Vista if the NetMsmqActivator service is enabled and Message Queuing (MSMQ) is not installed. The iisreset utility does not work unless MSMQ is installed or the

NetMsmqActivator service is disabled. The WCF samples setup script Setupvroot.bat will not run unless MSMQ is installed or the NetMsmqActivator service is disabled.

Make sure MSMQ is installed or disable the NetMsmqActivator service on Windows Vista before you run the WCF samples setup script Setupvroot.bat.

5.4.8 Some Samples Fail to Compile: Debug:Itanium Error
Some samples might fail to compile on all platforms with the following error:

vcbuild.exe: error VCBLD0004: Project 'C:\buildall_hxs\local\sampleexecutables\Technologies\DirectoryServices\BEREncoding\CP\BerEncoding\BerEncoding.vcproj' does not contain a configuration called 'Debug|Itanium'

This error occurs because platform configurations are listed alphabetically by default in a project or solution file created by Visual Studio. If Debug|Itanium is a supported configuration, it will be listed first in the samples' solution and/or project files.

To workaround this issue, use a configuration switch to specify what platform you want to build for:

Msbuild *.sln /p:platform=Win32
Msbuild *.sln /p:platform=x64
VCbuild *.vcproj /platform:Win32
VCbuild *.vcproj /platform:x64

5.4.9 .NET Compact Framework Samples Require Visual Studio to Compile
.NET Compact Framework samples in the Windows SDK will not compile without .targets files installed on your local disk atC:\Windows\https://www.360docs.net/doc/2d4062775.html,\Framework\\https://www.360docs.net/doc/2d4062775.html,pactFramework..targets

To workaround this issue, install either Visual Studio 2005 or 2008 to install the .targets files.

The affected samples are:

· CalculatorCS

· CalculatorVB

· MSMQSampleCS

· RomanLegionCS

· RomanLegionVB

· SliderPuzzleCS

· UltimateGmanCS

· BubbleCS

· BubbleVB

· BankClientCS

· POOMComInterop

· DeviceNotification

· RotatedTextCS

· RotatedText

· SqlCEResultSetSample

· WebCrawlerCS

5.4.10 Win32 WinUI\Speech\Tutorial Sample Fails to Compile
The Windows SDK Win32 sample WinUI\Speech\Tutorial fails to compile, generating the following error:

error PRJ0019: A tool returned an error code from "Performing Custom Build Step".

Issue: a Custom Build Step in the VC project files incorrectly references the GC.EXE tool (speech engine) with a relative path.

To workaround this issue, edit each of the sample’s .vcproj files, removing ..\..\..\bin\ at the start of the command-line for any "Grammars" files.

5.4.11 During the Build of a .NET Framework 3.0 or 3.5 Sample in the SDK Build Environment, Al.exe Might Not Be Found
When building a .NET Framework 3.0 or 3.5 sample in the SDK build environment, Al.exe is not found. (The ALTOOLPATH variable is set by Visual Studio 2005 to point to the .NET Framework 2.0 SDK, included with Visual Studio 2005.) You might receive this err

or:

Could not locate the .NET Framework SDK. The task is looking for the path t o the .NET Framework SDK at the location specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework. You may be able to solve the problem by doing one of the following: 1. ) Install the .NET Framework SDK. 2.) Manually set the above registry key to the correct location.

To workaround this issue, set the ALTOOLPATH environment variable to point to the version of Al.exe that ships in this Windows SDK. You can set ALTOOLPATH for an individual session using the Set command, or set the environment variable permanently at Start Control Panel System. On the Advanced tab, click the Environment Variables button. In the System variables area, click New. Add the variable name ALTOOLPATH with a Variable Value of one of the following:

· For X86 computers: C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin

· For x64 computers: C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\x64

· For IA64 computers: C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\IA64

5.4.12 Windows Media Services SDK Plug-ins Fail to Build on Windows 2008 Server
The “Playlistparser” and “Authorization” plug-in samples should be available in Windows Media Services. The user should be able to enable and disable the newly built plug-ins. However, the “Playlistparser” and “Authorization” plug-ins fail to build and produce the following error:

Syntax error for the code given below in Unknwn.idl

HRESULT QueryInterface(

[in] REFIID riid,

[out, iid_is(riid), annotation("__RPC__deref_out")] void **ppvObject);

To workaround this issue, build the “Playlistparser” and “Authorization” plug-ins on Windows Vista or Windows 2003 Server and copy the plug-ins to Windows 2008 Server.

5.4.13 XPS Rollup Sample Fails to Compile
The XPS Rollup code sample that installs to \samples\XPS\XpsRollup does not compile. A working updated version of the sample code can be found on Code Gallery: "https://www.360docs.net/doc/2d4062775.html,/fwlink/?LinkId=136633".

5.4.14 Deselecting .NET Framework Documentation Feature During Setup may Prevent Managed Code Samples and Associated Documents from Installing Correctly
When installing the SDK, users are given the option of deselecting certain components. It is possible to deselect the Documentation/.NET Framework component, while leaving the Samples/.NET Framework/Samples in Documentation selected. When this specific combination is chosen, the .NET Framework Samples will fail to install correctly and an installation error will be generated in the SDK Installation Log. If a user attempts to correct this issue by running the Change wizard in Programs and Features (Add Remove Programs on pre-Vista operating systems), the .NET Framework Documents will install correctly but the samples will still be missing.

Workaround 1:

Acces

s the .NET Framework samples directly opening the managed sample .zip files installed by default to \Program Files\Microsoft SDKs\Windows\7.0\Samples.

Workaround 2: Repair the SDK Installation

Open Programs and Features (Add Remove Programs on pre-Vista operating systems)
Select the Microsoft Windows SDK for Server 2008 and click Change
In the Maintenance screen, select Change
When presented with the Installation Options screen for setup, select the Documentation/.NET Framework component and click Next.
Once SDK setup is complete, Repair the SDK installation by following these steps:
Open Programs and Features (Add Remove Programs on pre-Vista operating systems)
Select the Microsoft Windows SDK for Server 2008 and click Change
In the Maintenance screen, select Repair

--------------------------------------------------------------------------------

6. Windows SDK Product Support and Feedback
The Windows SDK is provided as-is and is not supported by Microsoft. For technical support, there are a number of options:

6.1 Professional Support for Developers
Microsoft Professional Support for Developers provides incident-based access to Microsoft support professionals and rich information services to help developers to create and enhance their software solutions with Microsoft products and technologies.

For more information about Professional Support for Developers, or to purchase Professional Support incidents, please contact a Customer Representative at 1-800-936-3500. To access Professional Support for Developers, visit the MSDN Web site. If you have already purchased support incidents and would like to speak directly with a Microsoft support professional, call 1-800-936-5800.

6.2 MSDN Online
MSDN Online provides Developer Support search, support incident submission, support highlights, service packs, downloads, technical articles, API information, blogs, newsgroups, forums, webcasts, and other resources to help optimize development.

6.3 Ways to Find Support and Send Feedback
Your feedback is important to us. Your participation and feedback through the locations listed below is appreciated.

· The MSDN Forums are available for peer-to-peer support.

· Windows SDK Developer Center is the official site about development using the Windows SDK, and provides information about the SDKs, links to the Windows SDK Blog, Forum, online release notes and other resources.

· The Windows SDK Forum deals with topics related specifically to the Windows SDK.

· The Software Development for Windows Vista forum contains an updated list of related forums.

· You can also send mail to the Windows SDK Feedback alias at wsdkfdb@https://www.360docs.net/doc/2d4062775.html,.

· The Windows SDK Blog contains workarounds, late-breaking and forward-looking news.


相关主题
相关文档
最新文档