Zh/Compiling under VS2005: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
(Created page with "{{otherlang2 | de = Compiling_under_VS2005:de | ru = Compiling_under_VS2005:ru |en = Compiling_under_VS2005 }} {{toc-right}} Visual Studio 2005 is the officially-supported [...")
 
No edit summary
Line 7: Line 7:
{{toc-right}}
{{toc-right}}


Visual Studio 2005 is the officially-supported [[Wikipedia:Integrated development environment|IDE]] of the Source SDK, and if all is well you won't need to do anything special to use it. If you're using Visual C++ 2005 Express or if something is awry however, read on to get it up and running. '''This page assumes you are compiling the latest Orange Box source code.'''
Visual Studio 2005是SourceSDK的正式支持[[Wikipedia:Integrated development environment|IDE开发工具]],如果过程顺利,你并不需要设置什么特殊的步骤。如果您使用的是VS2005 Express版本,那么请继续阅读, '''本文假设您打算编译的是Orange Box版本的SDK'''


== Installing ==
== 安装 ==


Is it recommended to obtain the full Visual Studio 2005 Professional since it includes the Windows/Platform SDK.
建议您使用Visual Studio 2005 专业版,因为它包括了Windows/Platform SDK。
VCE2005 is no longer supported by or officially available from Microsoft. [http://download.microsoft.com/download/A/9/1/A91D6B2B-A798-47DF-9C7E-A97854B7DD18/VC.iso It can still be downloaded from Microsoft] Through it might disappear sometime soon!
VCE2005已经不在被微软官方支持。[http://download.microsoft.com/download/A/9/1/A91D6B2B-A798-47DF-9C7E-A97854B7DD18/VC.iso 不过它仍然可以从这里下载]。
当Vs或者vce已经安装完毕,建议您安装[https://support.microsoft.com/en-us/help/928957 SP1补丁] ([https://blogs.msdn.microsoft.com/heaths/2006/10/06/vs-2005-sp1-requires-a-lot-of-disk-space/注意它可能占用许多安装空间错误])以及[https://www.microsoft.com/en-us/download/details.aspx?id=7524 SP1的Vista更新].然后运行Windows更新来修复它(如果没有更新给VS/VSE,请不要担心)。


After Visual Studio or VCE has been installed, it is recommended to install [https://support.microsoft.com/en-us/help/928957 SP1] ([https://blogs.msdn.microsoft.com/heaths/2006/10/06/vs-2005-sp1-requires-a-lot-of-disk-space/ Be warned that it has a install bug of consuming a lot of space!])and [https://www.microsoft.com/en-us/download/details.aspx?id=7524 Vista Update for SP1]. Then run Windows Update to finish patching it. (If there are no updates for VS/VCE, don't worry)
== Windows SDK (仅限Express) ==


== Windows SDK (Express Only) ==
如果您使用的是VCE2005,您需要去安装Windows SDK。


If you're using Visual C++ Express 2005 you need to install the Windows SDK.


注意下面提供的Windows7 SDK会导致VS 2010出问题。


Be warned that the Windows 7 SDK offered below is known to cause issues with Visual Studio 2010 SP1.
<strike>不用在意您安装的版本</strike>*; [http://web.archive.org/web/20161108080358/http://www.microsoft.com/en-us/download/details.aspx?id=24826 它]会做的很好的。不要说vista了,它同样涵盖XP系统。


<strike>It doesn't matter which version you download</strike>*; [http://web.archive.org/web/20161108080358/http://www.microsoft.com/en-us/download/details.aspx?id=24826 this one does the job] well enough.  Don't worry that it talks about Vista - it also covers XP.
如果您是Windows2000用户(哦,现在还有吗?最低也是7系统吧,这篇教程估计很老了!)请看这个[[Compiling under VS2005/Older SDK|Older SDK]]


Windows 2000 users however should follow instructions in [[Compiling under VS2005/Older SDK|Older SDK]]
:''*:我非常确信您不必担心安装的版本,请看 [[#error C2733 referring to winnt.h or intrin.h|这里]]. -- [[User:Neverender|Neverender]] 17:26, 6 October 2012 (PDT)''


:''*: I'm pretty sure it does matter which version you download. See [[#error C2733 referring to winnt.h or intrin.h|below]]. -- [[User:Neverender|Neverender]] 17:26, 6 October 2012 (PDT)''
{{note|您只需安装“头和库”文件,大概有20Mb,完整的SDK将会有2GB!}}


{{note|You only need the "headers and libraries" component, about half-way through the list that the installer will present. They're about a 20MB download...the complete SDK is over 2GB!}}
{{note|如果您是64位系统用户,仍然选择默认的32位!}}


{{note|If you are installing on a 64bit OS, remember that it is still the 32bit (x86) libraries that you want. They aren't selected by default.}}
安装完毕后,您需要告诉vc++,windowsSDK的位置. 去做这个, 导航到 ''Tools/工具 > Options/选项 > Projects and Solutions/项目和解决方案 > VC++ Directories/VC++导航''.添加windowsSDK的<code>\bin</code>文件到列表。默认位于<code>C:\Program Files\Microsoft SDKs\Windows\v6.1\bin</code>。


Once you have the Windows SDK installed, you need to tell Visual C++ where the SDK is located. To do this, navigate to ''Tools > Options > Projects and Solutions > VC++ Directories''. Add the Windows SDK's <code>\bin</code> folder to the list. The default location is <code>C:\Program Files\Microsoft SDKs\Windows\v6.1\bin</code>.
点击drop_down表,实际叫“Executable files”,您需要将\include文件添加至incline表,以及\lib文件添加至library表。
 
Click on the drop-down list that ''currently'' says "Executable files". You need to add the <code>\include</code> folder to the 'Includes' list and the <code>\lib</code> folder to the 'Library' list.


[[Image:Vc2005 dirs.png|center|Adding the Windows SDK's includes.]]
[[Image:Vc2005 dirs.png|center|Adding the Windows SDK's includes.]]


{{tip|You'll need to go through a similar process if you've installed the DirectX SDK.}}
{{tip|如果您已安装directXSDK同样也要进行这个过程。}}


== Open the solution ==
== 打开解决方案 ==


# Launch your copy of '''Microsoft Visual Studio'''.
# 打开您的'''Microsoft Visual Studio'''.
# Select '''File-&gt;Open-&gt;Project/Solution''' from the menu and open the '''Game_Episodic-2005.sln''' solution located in your mod's <code>src</code> directory, select the one that matches your version of '''Microsoft Visual Studio'''.  If you selected mod from scratch, "Scratch" will appear there instead.
# 从菜单选择 '''File-&gt;Open-&gt;Project/Solution'''并打开 '''Game_Episodic-2005.sln''' 文件位于您的mod目录 <code>src</code> 内。选择适合您的'''Microsoft Visual Studio'''版本。


== LNK2019 errors ==
== LNK2019 错误 ==


If you receive these errors, right-click on the client and server projects in turn and select the last option in the menu, Properties. Then navigate to ''Configuration properties > Linker > Input'' and make the first item, "Additional Dependencies", read <code>winmm.lib user32.lib</code>. Make sure you've done this for both Debug and Release mode (switch between them in the top left of the Properties window).
如果您发现了这个错误,依次右键client和server项目,然后再菜单中选择最后一个选项, Properties. 然后导航至''Configuration properties > Linker > Input'' make the first item, "Additional Dependencies", 阅读 <code>winmm.lib user32.lib</code>. Make sure you've done this for both Debug and Release mode (switch between them in the top left of the Properties window).


If you get "unresolved external" errors, try adding <code>kernel32.lib</code> as well.
如果您出现了“无法解决的外部错误”,请尝试添加“kernel32.lib”。


== error C2733 referring to winnt.h or intrin.h ==
==引用winnt.h 或者 intrin.h的错误 C2733 ==


You may receive an error such as: "<code>error C2733: second C linkage of overloaded function '_interlockedbittestandreset' not allowed</code>"
您应该得到一个错误提示: "<code>error C2733: second C linkage of overloaded function '_interlockedbittestandreset' not allowed</code>"


This error is caused by trying to build against an incompatible version of the Windows SDK/Platform SDK. When using the full version of Visual C++ 2005, your Visual C++ directories (in "Options") should not refer to any newer external SDK include/lib paths; only the ones included with the Visual C++ 2005 installation by default. Reverting the "VC++ Directories" settings to default should solve this problem.
这个错误是尝试建立与windowsSDK/platform SDK不兼容版本产生的. 当使用vc++2005完整版时, 您的vc++目录("Options")不应该引用任何新版的外部sdk(包括include和lib); 默认情况下只能包括vc++2005的,恢复出产设置可以修复。


For '''Express users ONLY''', since you have no choice but to install an external SDK, [http://www.microsoft.com/en-us/download/details.aspx?id=6510 this version] may help. If '''all else fails''', some users have resorted to working around this problem by editing their SDK headers.
仅限'''Express用户''', 如果您没有好的选择去安装windowsSDK, [http://www.microsoft.com/en-us/download/details.aspx?id=6510 这个版本]可以提供帮助. 如果 '''都失败了''', 可以通过编辑SDK的header解决。


{{warning|Editing vendor provided header files is a '''BAD''' idea. This is a hack of last resort; however, by using Visual C++ Express, you are already working in an unsupported configuration.}}
{{warning|注意这并不是一个好方法,这是最后的手段(如果都不行)}}


Here are the previous instructions given:
以下是先前给出的说明:
:''"Open <code>C:\Program Files\Microsoft Visual Studio 8\VC\include\intrin.h</code> and comment out lines 944 and 945. If you continue to receive errors, comment out the referenced lines (typically 913 and 912) and recompile."''
:''"打开 <code>C:\Program Files\Microsoft Visual Studio 8\VC\include\intrin.h</code> 然后注释掉第944和945行,如果还不行注释掉912和913并重新编译"''


<i>You put the same download before in Windows SDK Express Only. : MatiasKiller21 [https://developer.valvesoftware.com/wiki/User:MatiasKiller21] : July 01 2015.</i>
<i>You put the same download before in Windows SDK Express Only. : MatiasKiller21 [https://developer.valvesoftware.com/wiki/User:MatiasKiller21] : July 01 2015.</i>


== Running your mod ==
== 启动您的mod ==


Remember to run with -allowdebug if you've got debug builds!
如果您是debug版本,请与-allowdebug运行。


== See also ==
== 参见 ==


* [[Compiling under VS2010]]
* [[Compiling under VS2010]]

Revision as of 23:56, 6 March 2020

Template:Otherlang2

Visual Studio 2005是SourceSDK的正式支持IDE开发工具,如果过程顺利,你并不需要设置什么特殊的步骤。如果您使用的是VS2005 Express版本,那么请继续阅读, 本文假设您打算编译的是Orange Box版本的SDK

安装

建议您使用Visual Studio 2005 专业版,因为它包括了Windows/Platform SDK。 VCE2005已经不在被微软官方支持。不过它仍然可以从这里下载。 当Vs或者vce已经安装完毕,建议您安装SP1补丁 ([1])以及SP1的Vista更新.然后运行Windows更新来修复它(如果没有更新给VS/VSE,请不要担心)。

Windows SDK (仅限Express)

如果您使用的是VCE2005,您需要去安装Windows SDK。


注意下面提供的Windows7 SDK会导致VS 2010出问题。

不用在意您安装的版本*; 会做的很好的。不要说vista了,它同样涵盖XP系统。

如果您是Windows2000用户(哦,现在还有吗?最低也是7系统吧,这篇教程估计很老了!)请看这个Older SDK

*:我非常确信您不必担心安装的版本,请看 这里. -- Neverender 17:26, 6 October 2012 (PDT)
Note.png注意:您只需安装“头和库”文件,大概有20Mb,完整的SDK将会有2GB!
Note.png注意:如果您是64位系统用户,仍然选择默认的32位!

安装完毕后,您需要告诉vc++,windowsSDK的位置. 去做这个, 导航到 Tools/工具 > Options/选项 > Projects and Solutions/项目和解决方案 > VC++ Directories/VC++导航.添加windowsSDK的\bin文件到列表。默认位于C:\Program Files\Microsoft SDKs\Windows\v6.1\bin

点击drop_down表,实际叫“Executable files”,您需要将\include文件添加至incline表,以及\lib文件添加至library表。

Adding the Windows SDK's includes.
Tip.png提示:如果您已安装directXSDK同样也要进行这个过程。

打开解决方案

  1. 打开您的Microsoft Visual Studio.
  2. 从菜单选择 File->Open->Project/Solution并打开 Game_Episodic-2005.sln 文件位于您的mod目录 src 内。选择适合您的Microsoft Visual Studio版本。

LNK2019 错误

如果您发现了这个错误,依次右键client和server项目,然后再菜单中选择最后一个选项, Properties. 然后导航至Configuration properties > Linker > Input 并 make the first item, "Additional Dependencies", 阅读 winmm.lib user32.lib. Make sure you've done this for both Debug and Release mode (switch between them in the top left of the Properties window).

如果您出现了“无法解决的外部错误”,请尝试添加“kernel32.lib”。

引用winnt.h 或者 intrin.h的错误 C2733

您应该得到一个错误提示: "error C2733: second C linkage of overloaded function '_interlockedbittestandreset' not allowed"

这个错误是尝试建立与windowsSDK/platform SDK不兼容版本产生的. 当使用vc++2005完整版时, 您的vc++目录(在 "Options")不应该引用任何新版的外部sdk(包括include和lib); 默认情况下只能包括vc++2005的,恢复出产设置可以修复。

仅限Express用户, 如果您没有好的选择去安装windowsSDK, 这个版本可以提供帮助. 如果 都失败了, 可以通过编辑SDK的header解决。

Warning.png警告:注意这并不是一个好方法,这是最后的手段(如果都不行)

以下是先前给出的说明:

"打开 C:\Program Files\Microsoft Visual Studio 8\VC\include\intrin.h 然后注释掉第944和945行,如果还不行注释掉912和913并重新编译"

You put the same download before in Windows SDK Express Only. : MatiasKiller21 [2] : July 01 2015.

启动您的mod

如果您是debug版本,请与-allowdebug运行。

参见