Compiling under VS2010: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(some cleanup, still a bit of a mess though)
Line 5: Line 5:
'''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.
'''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.


== Alien Swarm conversion ==
{{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; $File</code>" from line 2232.}}


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; $File</code>" from line 2232.
== Debugging ==


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


== Compiling and Launching ==
== File Copying ==


1. Goto wherever you have saved your source code i.e(C:\Users\-Username-\Desktop\Mymod\src) Note that the file Game_Episodic.sln is a Visual Studio Solution.
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 ''$(TargetPath)''.


2. Open Visual Studio 2010, and on the top right corner click File>Open>Project/Solution. Open Game_Episodic.sln(A progress bar can be seen on the bottom)
== IsBIK error ==
{{note|In order to succesfully navigate you will need the Solution Explorer open. Goto View>Other Windows>Solution Explorer}}


3. Right-click the project and select build. Build both of them. When building, you will most likely not be successful. The errors and such will have solutions below.
First, save [http://pastebin.com/4NTMCcmb this code] to <code>src/public/avi/ibik.h</code>.
Then in <code>src/game/client/enginesprite.h</code> include <code>avi/ibik.h</code> and add insert the hightlighted lines toward the bottom:


4. Follow the instructions at [[Launching from Visual Studio]]
<source lang=cpp highlight=2,7>
bool IsAVI();
bool IsBIK();
void GetTexCoordRange( float *pMinU, float *pMinV, float *pMaxU, float *pMaxV );
private:
AVIMaterial_t m_hAVIMaterial;
BIKMaterial_t m_hBIKMaterial;</source>


== Debugging ==
Now open <code>spritemodel.cpp</code> and add the following:


# Follow the instructions [[Compiling under VS2008#Fix debug compilation|for fixing debug compiles in VS2008]], which apply here as well.
<source lang=cpp>
# 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.
bool CEngineSprite::IsBIK()
{
return ( m_hBIKMaterial != BIKMATERIAL_INVALID );
}
</source>


== Fixing File Copying ==
== Fixing Other Compiling Errors ==


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, so if your changes aren't taking effect, this may be the cause. 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)''
; Error LNK2005<nowiki>:</nowiki> ... already defined in memoverride.obj
: For each affected project right-click on it, go to ''Properties->Configuration Properties->Linker->Command Line'' and in ''Additional Options'' add the following: "/FORCE:MULTIPLE".
; Linker Errors relating to LIBC, LIBCMT, LIBCD, LIBCMTD
: 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" (glview only)
: Remove the line <code>#include <gl/glaux.h></code> from <code>glview.cpp</code>. Then right-click on the project and go to ''Properties->Configuration Properties->Linker->Input'' and under ''Additional Dependencies'' remove <code>glaux.lib</code>.


== Fixing Warnings ==
== 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:
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:
Line 37: Line 55:
# hud_credits.cpp
# hud_credits.cpp
# hud_flashlight.cpp
# hud_flashlight.cpp
== Fixing "'IsBIK': identifier not found" error ==
First, save [http://pastebin.com/4NTMCcmb this code] at src/public/avi/ibik.h .
Then, under "src/game/client/enginesprite.h", include "avi/ibik.h" at the top and add the following parts (only the ones in bold) toward 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;'''
Then in spritemodel.cpp, add the following under the end of CEngineSprite::IsAVI():
//-----------------------------------------------------------------------------
// Is the sprite an BIK?
//-----------------------------------------------------------------------------
bool CEngineSprite::IsBIK()
{
return ( m_hBIKMaterial != BIKMATERIAL_INVALID );
}
It should build and run fine.
== Fixing Other Compiling Errors ==
Fixes:
#Cannot locate "gl/glaux.h" - this library is not even used anywhere, why a reference to it still exists is beyond me. It also seems to be obsolete. To get around this error simply comment out the line "#include <gl/glaux.h>" inside glview.cpp under the Glview project. Secondly right-click on the project Glview and go to Properties, then find Configuration Properties->Linker->Input and under Additional Dependencies remove the text "glaux.lib;"
#"error LNK2005: ... already defined in memoverride.obj" - this one is simple to deal with, and will probably occur in one or two projects. For each affected project simply right-click on it, go to Properties, then find Configuration Properties->Linker->Command Line and in the "Additional Options" text box add the following: "/FORCE:MULTIPLE". If that doesn't work, just change the configuration from "Debug" to "Release".
#Linker Errors relating to LIBC, LIBCMT, LIBCD, LIBCMTD, - Go to the client project properties -> Linker -> Input -> Ignore Specific Default Libraries -> and enter "libc;libcmtd;libcd;" without the quotation marks. Navigate to the same place in the server project properties and enter "libcd;libcmtd", again without the quotations.


== 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 ==

Revision as of 09:40, 30 May 2011

Template:Otherlang2

Visual studio logo.png

Visual Studio 2010 is the best choice for Source. You can use the free C++ Express edition.

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.  [todo tested in ?]

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 this code to src/public/avi/ibik.h. Then in src/game/client/enginesprite.h include avi/ibik.h and add insert the hightlighted lines toward 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 and add the following:

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

Fixing Other Compiling Errors

Error LNK2005: ... already defined in memoverride.obj
For each affected project right-click on it, go to Properties->Configuration Properties->Linker->Command Line and in Additional Options add the following: "/FORCE:MULTIPLE".
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. Then right-click on the project and go to Properties->Configuration Properties->Linker->Input and under Additional Dependencies remove glaux.lib.

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

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