This article's documentation is for anything that uses the Source engine. Click here for more information.

Compiling under VS2010: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
(18 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{otherlang2|
{{LanguageBar}}{{source topicon}}[[Category:Programming]][[Category:Source SDK FAQ]][[Category:Tutorials]]
ru=Compiling under VS2010:ru|
{{TabsBar|main=Visual Studio}}
de=Compiling under VS2010:de}}
{{Outdated sdk|{{astools|4.1|nt=1}}|newer-sdk-equivalent=[[Compiler choices]]. For compiling {{srcsdk13sp|1}}, follow [[Setting_up_Source_SDK_Base_2013_Singleplayer#Windows|same instructions]] as VS2013, but simply add {{code|/2010}} to your VPC command line}}
[[File:Visual studio logo.png|right]]
[[File:Visual studio logo.png|right]]


'''Visual Studio 2010''' is the best choice for Source. You can use the free [http://www.microsoft.com/express/Downloads/#2010-Visual-CPP C++ Express] edition.
{{bug|hidetested=1|Converting the Alien Swarm server project to VS2010 will lead to an "invalid characters in path" error. To fix it, open <code>game\server\swarm_sdk_server.vcproj</code> with a text editor and delete "<code>&apos;&#x0A;$File</code>" from line 2232.}}
 
{{bug|Converting the Alien Swarm server project to VS2010 will lead to an "invalid characters in path" error. To fix it, open <code>game\server\swarm_sdk_server.vcproj</code> with a text editor and delete "<code>&apos;&#x0A;$File</code>" from line 2232.}}


== Debugging ==
== Debugging ==
# Follow the instructions [[Compiling under VS2008#Fix debug compilation|for fixing debug compiles in VS2008]], which apply here as well.
# Follow the instructions [[Compiling under VS2008#Fix debug compilation|for fixing debug compiles in VS2008]], which apply here as well.
# Right click on the client and server projects in VS and go to ''Properties > Configuration Properties > General''. Change ''Target Name'' to ''client'' and ''server'' respectively.
# Right click on the client and server projects in VS and go to ''Properties > Configuration Properties > General''. Change ''Target Name'' to ''client'' and ''server'' respectively.


== File Copying ==
== File Copying ==
There is a [http://connect.microsoft.com/VisualStudio/feedback/details/603666/custom-build-steps-do-not-run-in-visual-c-visual-studio-2010#details bug] in VS 2010 which will sometimes prevent your newly-compiled DLLs from being copied to your mod directory. To fix it, right-click on the client and server projects in VS and select ''Properties''. Change the ''Configuration'' drop-down menu at the top to ''All Configurations''. Then, go to ''Configuration Properties > Custom Build Step'' and in the ''Additional Dependencies'' field, type in <tt>$[TargetPath]</tt>.


Es gibt einen [http://connect.microsoft.com/VisualStudio/feedback/details/603666/custom-build-steps-do-not-run-in-visual-c-visual-studio-2010#details bug] in VS2010, welcher manchmal verhindert das die neu kompilierten DLLs in das Verzeichniss deiner Mod kopiert verden. Um das zu verhindern, rechtsklicke jeweils das Client- und dass Server-Projekt in VS und wähle ''Einstellungen'' (''Properties'') aus. Verändere das drop-down Menü ''Konfiguration'' (''Configuration'') oben links zu ''Alle Konfigurationen'' (''All Configurations''). Danach wähle ''Konfigurationseigenschaften > Benutzerdefinierter Buildschritte'' (''Configuration Properties > Custom Build Step'') und gebe im Feld ''Zusätzliche Abbhängigkeiten'' (''Additional Dependencies'') "''$(TargetPath)''" ein.
== IsBIK error ==
 
First, save [https://developer.valvesoftware.com/wiki/Source_SDK_missing_files ibik.h] to <tt>src/public/avi/ibik.h</tt>.
== IsBIK Error ==
Then in <tt>src/game/client/enginesprite.h</tt>, add to the include list:
 
Zuerst speichere [https://developer.valvesoftware.com/wiki/Source_SDK_missing_files ibik.h] in <code>src/public/avi/ibik.h</code> ab.
Dann füge folgendes zur Includelist von <code>src/game/client/enginesprite.h</code> hinzu:


<source lang=cpp>
<source lang=cpp>
Line 26: Line 21:
</source>
</source>


Als nächstes musst Du die folgenden Zeilen Code in der Nähe von Zeile ''53'' (irgentwo am Ende) hinzufügen:
Next, add the highlighted lines towards the bottom:


<source lang=cpp highlight=2,7>
<source lang=cpp highlight=2,7>
Line 37: Line 32:
BIKMaterial_t m_hBIKMaterial;</source>
BIKMaterial_t m_hBIKMaterial;</source>


Als letztes musst Du <code>spritemodel.cpp</code>(im selben ordner) öffnen und da wo Platz ist das hier hinzufügen:
Now open <code>spritemodel.cpp</code> (located in the same directory) and add the following:


<source lang=cpp>
<source lang=cpp>
Line 46: Line 41:
</source>
</source>


== Beheben von anderen Fehlern bie der Kompilierung ==
== Fixing Other Compiling Errors ==
 
; Error LNK2005<nowiki>:</nowiki> ... already defined in memoverride.obj
; Error LNK2005<nowiki>:</nowiki> ... already defined in memoverride.obj
: Schaue unter [[Compiling under VS2008#Fix debug compilation]].
: See [[Compiling under VS2008#Fix debug compilation]].
; Linker Fehler die mit LIBC, LIBCMT, LIBCD, LIBCMTD zutun haben
; Linker Errors relating to LIBC, LIBCMT, LIBCD, LIBCMTD
: Gehe in die Einsellungen vom Client-Projekt ''Einstellungen->Liker->Eingabe->Bestimmte Standartbibliotheken ignorieren'' (''Properties->Linker->Input->Ignore Specific Default Libraries'') und gebe <code>libc;libcmtd;libcd;</code> ein. Gehe an die gleiche stelle in den Servereinstellungen und gebe <code>libcd;libcmtd;</code> ein.
: Go to the client project's ''Properties->Linker->Input->Ignore Specific Default Libraries'' and enter <code>libc;libcmtd;libcd;</code>. Navigate to the same place in the server project properties and enter <code>libcd;libcmtd;</code>.
; Cannot locate "gl/glaux.h" (nur glview)
; Cannot locate "gl/glaux.h" (glview only)
: Entferne die Zeile <code>#include <gl/glaux.h></code> aus <code>glview.cpp</code> (gespeichert unter src/utils/glview). Dann rechtsklicke das Projekt und gehe zu ''Einstellungen->Konfigurationseigenschaften->Linker->Eingabe'' (''Properties->Configuration Properties->Linker->Input'') und entferne <code>glaux.lib</code> aus ''Zusätzliche Abhängigkeiten'' (''Additional Dependencies'').
: Remove the line <code>#include <gl/glaux.h></code> from <code>glview.cpp</code> (can be found in src/utils/glview). Then right-click on the project and go to ''Properties->Configuration Properties->Linker->Input'' and under ''Additional Dependencies'' remove <code>glaux.lib</code>.
; Warning MSB8012<nowiki>:</nowiki> TargetPath does not match the Linker's OutputFile property ...
; Warning MSB8012<nowiki>:</nowiki> TargetPath does not match the Linker's OutputFile property ...
: Gehe zu ''Einstellungen->Konfigurationseigenschaften->Allgemein'' (''Properties->Configuration Properties->General''). Verändere den Inhalt von ''Ausgabeverzeichniss'' (''Output Directory''), ''Zwischenverzeichniss'' (''Intermediate Directory''), ''Zielname'' (''Target Name''), und ''Zielerweiterung'' (''Target Extension'') so, das sie dem in der Fehlermeldung angegebenen Dateipfad entspricht.
: Go to ''Properties->Configuration Properties->General''. Change the values in ''Output Directory'', ''Intermediate Directory'', ''Target Name'', and ''Target Extension'' to match the Linker's OutputFile property value given in the error message.
 
;fatal error C1083<nowiki>:</nowiki> Cannot open include file<nowiki>:</nowiki> <nowiki>'</nowiki>weapon_sdkbase.h<nowiki>'</nowiki><nowiki>:</nowiki> No such file or directory
;fatal error C1083<nowiki>:</nowiki> Cannot open include file<nowiki>:</nowiki> <nowiki>'</nowiki>weapon_sdkbase.h<nowiki>'</nowiki><nowiki>:</nowiki> No such file or directory
: Schaue in den Artikel <nowiki>:</nowiki> http://developer.valvesoftware.com/wiki/Source_SDK_missing_files
: See [[Source SDK missing files#weapon_sdkbase]]
 
== Vorkompilierte Headers ==
 
Wenn Du die "Vorkompilierter Header" bzw. "Precompiled Header" Warnungen loswerden möchtest, dann öffne diese Datein und bewege <code>#include "cbase.h"</code> in die erste Zeile:


== Precompiled Headers ==
If you want to remove the "precompiled header" warnings seen during a full compile, open these files in your client project and move <code>#include "cbase.h"</code> up to the first line:
# hud_locator.cpp
# hud_locator.cpp
# hud_credits.cpp
# hud_credits.cpp
Line 69: Line 60:


== First-chance exception at 0x00000000 ==
== First-chance exception at 0x00000000 ==
 
If Client compiles but Server does not, and you have set your mod up for debugging, <tt>hl2.exe</tt> will crash with extremely ambiguous information. To prevent the game from running if Server does not successfully compile, right click the client project file and select ''Project Dependencies''. Check the checkbox for Server and then click ''OK''.
If Client compiles but Server does not, and you have set your mod up for debugging, hl2.exe will crash with extremely ambiguous information. To prevent the game from running if Server does not successfully compile, right click the client project file and select ''Project Dependencies''. Check the checkbox for Server and then click ''OK''.


== Compiling Under Linux ==
== Compiling Under Linux ==
VS 2010 introduces a new project file format (<code>.vcxproj</code>) which is not compatible with the SDK's <code>VprojToMake</code> tool. [[Vprojtomake 2010|A third-party update adding support is available.]]
VS 2010 introduces a new project file format (<code>.vcxproj</code>) which is not compatible with the SDK's <code>VprojToMake</code> tool. [[Vprojtomake 2010|A third-party update adding support is available.]]


== See also ==
== See also ==
* [http://www.microsoft.com/visualstudio/en-us/products/2010-editions/ Visual Studio 2010]
* [http://www.microsoft.com/visualstudio/en-us/products/2010-editions/ Visual Studio 2010]
* [[Launching from Visual Studio]]
* [[Launching from Visual Studio]]
 
* [[Compiling under VS2005]]
[[Category:Tutorials]]
* [[Compiling under VS2008]]
[[Category:Programming]]
* [[Compiling under VS2012]]
[[Category:Source SDK FAQ]]

Latest revision as of 02:58, 20 June 2025

English (en)Deutsch (de)Русский (ru)Translate (Translate)
Visual Studio compilers: edit
Ambox warning yellow.png
This page was written for Alien Swarm - SDK Alien Swarm Authoring Tools or earlier. It may not be applicable to newer versions of the Source SDK.
For more up-to-date information, see Compiler choices. For compiling Source SDK Base 2013 - Singleplayer, follow same instructions as VS2013, but simply add /2010 to your VPC command line.
Visual studio logo.png
Icon-Bug.pngBug:Converting the Alien Swarm server project to VS2010 will lead to an "invalid characters in path" error. To fix it, open game\server\swarm_sdk_server.vcproj with a text editor and delete "' $File" from line 2232.

Debugging

  1. Follow the instructions for fixing debug compiles in VS2008, which apply here as well.
  2. Right click on the client and server projects in VS and go to Properties > Configuration Properties > General. Change Target Name to client and server respectively.

File Copying

There is a bug in VS 2010 which will sometimes prevent your newly-compiled DLLs from being copied to your mod directory. To fix it, right-click on the client and server projects in VS and select Properties. Change the Configuration drop-down menu at the top to All Configurations. Then, go to Configuration Properties > Custom Build Step and in the Additional Dependencies field, type in $[TargetPath].

IsBIK error

First, save ibik.h to src/public/avi/ibik.h. Then in src/game/client/enginesprite.h, add to the include list:

#include "avi/ibik.h"

Next, add the highlighted lines towards the bottom:

bool IsAVI();
bool IsBIK();
void GetTexCoordRange( float *pMinU, float *pMinV, float *pMaxU, float *pMaxV );
 
private:
AVIMaterial_t m_hAVIMaterial;
BIKMaterial_t m_hBIKMaterial;

Now open spritemodel.cpp (located in the same directory) and add the following:

bool CEngineSprite::IsBIK()
{
	return ( m_hBIKMaterial != BIKMATERIAL_INVALID );
}

Fixing Other Compiling Errors

Error LNK2005: ... already defined in memoverride.obj
See Compiling under VS2008#Fix debug compilation.
Linker Errors relating to LIBC, LIBCMT, LIBCD, LIBCMTD
Go to the client project's Properties->Linker->Input->Ignore Specific Default Libraries and enter libc;libcmtd;libcd;. Navigate to the same place in the server project properties and enter libcd;libcmtd;.
Cannot locate "gl/glaux.h" (glview only)
Remove the line #include <gl/glaux.h> from glview.cpp (can be found in src/utils/glview). Then right-click on the project and go to Properties->Configuration Properties->Linker->Input and under Additional Dependencies remove glaux.lib.
Warning MSB8012: TargetPath does not match the Linker's OutputFile property ...
Go to Properties->Configuration Properties->General. Change the values in Output Directory, Intermediate Directory, Target Name, and Target Extension to match the Linker's OutputFile property value given in the error message.
fatal error C1083: Cannot open include file: 'weapon_sdkbase.h': No such file or directory
See Source SDK missing files#weapon_sdkbase

Precompiled Headers

If you want to remove the "precompiled header" warnings seen during a full compile, open these files in your client project and move #include "cbase.h" up to the first line:

  1. hud_locator.cpp
  2. hud_credits.cpp
  3. hud_flashlight.cpp

First-chance exception at 0x00000000

If Client compiles but Server does not, and you have set your mod up for debugging, hl2.exe will crash with extremely ambiguous information. To prevent the game from running if Server does not successfully compile, right click the client project file and select Project Dependencies. Check the checkbox for Server and then click OK.

Compiling Under Linux

VS 2010 introduces a new project file format (.vcxproj) which is not compatible with the SDK's VprojToMake tool. A third-party update adding support is available.

See also