Compiling under VS2022: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(26 intermediate revisions by 12 users not shown)
Line 1: Line 1:
{{LanguageBar}}
{{TabsBar|main=Visual Studio}}
{{stub}}
{{stub}}
{{Note|Sorry that this article is a bit of a stub! I wanted to make sure it at least existed for those looking to use a modern compiler with the 2013 SDK. It is absolutely reasonable to use the latest compilers with the SDK! I would suggest using the diffs from the two GitHub repos linked on this page for figuring it out for your mod.}}


== Multiplayer (TF2 branch) ==
The {{tf2branch|2|nt=1}} officially supports compiling using Visual Studio 2022. See [[Setting up Source SDK Base 2013 Multiplayer]] for more information.


With Visual Studio 2013 becoming older harder to obtain, using Microsoft's (as of writing) actively supported and updated Visual Studio 2022 becomes a no-brainier. As it is not be the officially-supported [[Wikipedia:Integrated development environment|IDE]] of the Source SDK, some work is required to get it all functioning.
== 2013 Singleplayer + Multiplayer Legacy ==
{{Note|Sorry that this article is a bit of a stub! I wanted to make sure it at least existed for those looking to use a modern compiler with the 2013 SDK. It is absolutely reasonable to use the latest compilers with the SDK! I would suggest using the diffs from the two GitHub repos linked on this page for figuring it out for your mod.
<small>- [[User:Ozxybox]]</small>
}}


This article is primarily based on these two GitHub repos
With Visual Studio 2013 being out of support, and harder to obtain, there is a lot of pressure to use a newer version of Visual Studio when working with Source SDK 2013. However, as the codebase does not support the changes brought about by later toolset versions, some work is required to get it functioning.
* https://github.com/ozxybox/source-mp13-vs2022
* https://github.com/Joshua-Ashton/Source-PlusPlus


== Running VPC ==
This article is primarily based on these two GitHub repos:
* https://github.com/Source-SDK-Resources/source-sdk-vs2022
* https://github.com/SCell555/Source-PlusPlus


If you don't have an older version of Visual Studio on your computer, VPC will fail to run, as it can't find certain registry keys specific to these older versions.
If necessary, these changes can also be made to work with VS2015—VS2019 by changing <code>$PlatformToolset</code> in <code>source_win32_base.vpc</code>.


The best solution is to go grab an edit of VPC that works for modern versions of Visual Studio.
=== "I'm starting from scratch!" ===
https://github.com/Joshua-Ashton/Source-PlusPlus/blob/master/src/devtools/bin/vpc.exe
If you don't want to deal with setting up the project, or if you have problems compiling the source code because of certain errors, you can clone [https://github.com/Source-SDK-Resources/source-sdk-vs2022 this repo] since it's based on the official {{Src13|4}} repo with minimal changes to allow it to run without problems. Please disregard any "compile process successful but file not found" warning as it is meaningless.


Another solution would be to add the registry keys VPC is looking for.
=== Using {{mapbase|4}} ===
{{Todo|Provide the registry keys needed here.}}
Mapbase can be compiled with any version of Visual Studio, from 2013-2022. You can toggle support by editing {{path|\vpc_scripts\newer_vs_toolsets|vpc}}


Once running the VPC scripts will need to be modified to support the newer toolsets.
=== Editing Existing Code ===
{{Todo|Explain changes from here https://github.com/ozxybox/source-mp13-vs2022/tree/master/mp/src/vpc_scripts}}
If you need to edit an existing codebase (Such as the version of {{src13|3.1}} Valve provides on GitHub), you will need to edit or replace certain files.


== Fixing particles.lib ==
==== Running VPC ====
If you don't have Visual Studio 2013 on your computer, [[VPC]] will fail to run, as it can't find registry keys specific to older versions.


Once everything's compiling, you'll hit a snag with '''particles.lib'''. It defines the symbol _hypot, and in VS 2022, that symbol is already getting used up.  
You can:
* Grab an edit of VPC that works for modern versions of Visual Studio, [https://github.com/SCell555/Source-PlusPlus/blob/HEAD/src/devtools/bin/vpc.exe  such as this one]
 
* Add the registry keys VPC is looking for. See [[Source SDK 2013#Unable to find RegKey for .vcproj files in solutions (Windows)|here]].
 
Once ran, the generated VPC scripts will need to be modified to support the newer toolsets.
{{Todo|Explain changes from here https://github.com/Source-SDK-Resources/source-sdk-vs2022/tree/master/mp/src/vpc_scripts}}
 
==== Fixing {{code|particles.lib}} ====
Once everything's compiling, you'll hit a snag with '''particles.lib'''. It defines the symbol _hypot, and when using VS 2022, that symbol is already being used.  


The best solution for this is to go grab an edit of '''particles.lib''' that's been fixed.
The best solution for this is to go grab an edit of '''particles.lib''' that's been fixed.
https://github.com/Joshua-Ashton/Source-PlusPlus/blob/master/src/lib/public/particles.lib
[https://github.com/SCell555/Source-PlusPlus/blob/HEAD/src/lib/public/particles.lib (Like this one)]


If you're not a fan of that idea, one alternative could be telling VPC to allow multiple symbols to exist for the client project. This is not a great practice though!
If you're not a fan of that idea, one alternative could be telling VPC to allow multiple symbols to exist for the client project. This is not a great practice though!
https://github.com/ozxybox/source-mp13-vs2022/blob/7be91d3ddc4388ec43a60195f6d959682a256cbe/mp/src/game/client/client_base.vpc#L74
[https://github.com/Source-SDK-Resources/source-sdk-vs2022/blob/7be91d3ddc4388ec43a60195f6d959682a256cbe/mp/src/game/client/client_base.vpc#L74| Example]
 
==== Fixing {{code|memoverride.cpp}} ====
The main file that needs to be fixed for Source to work under VS 2022 is {{file|memoverride|cpp}}. Replace it with [https://github.com/Source-SDK-Resources/source-sdk-vs2022/blob/master/mp/src/public/tier0/memoverride.cpp this one].


== Fixing '''memoverride.cpp''' ==
{{Todo|Explain everything from here https://github.com/Source-SDK-Resources/source-sdk-vs2022/blob/master/mp/src/public/tier0/memoverride.cpp}}


The main file that needs to be fixed for Source to work under VS 2022 is '''memoverride.cpp'''.
=== In Recap ===
Do what [[Setting up Source SDK Base 2013 Singleplayer|this page]] asks you to do while ignoring any reference to Visual Studio 2013, fix the Registry keys problem with the fix from the same page, download '''particles.lib''' to {{path|<mp or sp>\src\lib\public}} from [https://github.com/SCell555/Source-PlusPlus/blob/HEAD/src/lib/public/particles.lib this], and finally, replace {{file|memoverride|cpp}} located at {{path|<mp or sp>\src\public\tier0}} with [https://github.com/Source-SDK-Resources/source-sdk-vs2022/blob/master/mp/src/public/tier0/memoverride.cpp this one]. Have fun making Source mods with updated software ;)


{{Todo|Explain everything from here https://github.com/ozxybox/source-mp13-vs2022/blob/master/mp/src/public/tier0/memoverride.cpp}}
[[Category:Tutorials]]
[[Category:Programming]]
[[Category:Source SDK FAQ]]

Latest revision as of 16:25, 3 July 2025

English (en)Translate (Translate)
Visual Studio compilers: edit

Stub

This article or section is a stub. You can help by expanding it.

Multiplayer (TF2 branch)

The Team Fortress 2 branch Team Fortress 2 engine branch officially supports compiling using Visual Studio 2022. See Setting up Source SDK Base 2013 Multiplayer for more information.

2013 Singleplayer + Multiplayer Legacy

Note.pngNote:Sorry that this article is a bit of a stub! I wanted to make sure it at least existed for those looking to use a modern compiler with the 2013 SDK. It is absolutely reasonable to use the latest compilers with the SDK! I would suggest using the diffs from the two GitHub repos linked on this page for figuring it out for your mod.

- User:Ozxybox

With Visual Studio 2013 being out of support, and harder to obtain, there is a lot of pressure to use a newer version of Visual Studio when working with Source SDK 2013. However, as the codebase does not support the changes brought about by later toolset versions, some work is required to get it functioning.

This article is primarily based on these two GitHub repos:

If necessary, these changes can also be made to work with VS2015—VS2019 by changing $PlatformToolset in source_win32_base.vpc.

"I'm starting from scratch!"

If you don't want to deal with setting up the project, or if you have problems compiling the source code because of certain errors, you can clone this repo since it's based on the official Source 2013 Source 2013 repo with minimal changes to allow it to run without problems. Please disregard any "compile process successful but file not found" warning as it is meaningless.

Using Mapbase Mapbase

Mapbase can be compiled with any version of Visual Studio, from 2013-2022. You can toggle support by editing 🖿\vpc_scripts\newer_vs_toolsets.vpc

Editing Existing Code

If you need to edit an existing codebase (Such as the version of Source 2013 Valve provides on GitHub), you will need to edit or replace certain files.

Running VPC

If you don't have Visual Studio 2013 on your computer, VPC will fail to run, as it can't find registry keys specific to older versions.

You can:

  • Grab an edit of VPC that works for modern versions of Visual Studio, such as this one
  • Add the registry keys VPC is looking for. See here.

Once ran, the generated VPC scripts will need to be modified to support the newer toolsets.

Todo: Explain changes from here https://github.com/Source-SDK-Resources/source-sdk-vs2022/tree/master/mp/src/vpc_scripts

Fixing particles.lib

Once everything's compiling, you'll hit a snag with particles.lib. It defines the symbol _hypot, and when using VS 2022, that symbol is already being used.

The best solution for this is to go grab an edit of particles.lib that's been fixed. (Like this one)

If you're not a fan of that idea, one alternative could be telling VPC to allow multiple symbols to exist for the client project. This is not a great practice though! Example

Fixing memoverride.cpp

The main file that needs to be fixed for Source to work under VS 2022 is 🖿memoverride.cpp. Replace it with this one.

Todo: Explain everything from here https://github.com/Source-SDK-Resources/source-sdk-vs2022/blob/master/mp/src/public/tier0/memoverride.cpp

In Recap

Do what this page asks you to do while ignoring any reference to Visual Studio 2013, fix the Registry keys problem with the fix from the same page, download particles.lib to 🖿<mp or sp>\src\lib\public from this, and finally, replace 🖿memoverride.cpp located at 🖿<mp or sp>\src\public\tier0 with this one. Have fun making Source mods with updated software ;)