source-engine icon indicating copy to clipboard operation
source-engine copied to clipboard

[Guide] How to succesfully compile and run on windows.

Open maksw2 opened this issue 1 year ago • 33 comments

This guide will tell you how to prepare, compile and run build game.

  1. Install visual studio 2017 or 2022 with vs 2017 build tools, git or github desktop and python 3
  2. Cloning a. clone with git: git clone https://github.com/nillerusr/source-engine.git --recursive b. clone with github desktop.
  3. Go into command prompt and run these commands: waf.bat configure -T release --prefix=hl2 --build-games=hl2 --disable-warns waf.bat build -p -v waf.bat install
  4. now you have a directory called "hl2" with all binaries
  5. copy hl2 and platform from your hl2 install (steam) (skip overwriting files) (if you build any other game also copy it's folder)
  6. double click on hl2_launcher.exe

OTHER IMPORTANT THINGS

  1. want voice chat? add --enable-opus to configure
  2. change build game? change --prefix and --build-games in configure hl1 = Half-Life 1: Source hl2 = Half-Life 2 // Default - This will be selected if you don't specify a game episodic = Half-Life 2 Episode 1 ep2 = Half-Life 2 Episode 2 // Do not build for ep2, use episodic instead. hl2mp = Half-Life 2: Deathmatch dod = Day of Defeat cstrike = Counter-Strike: Source portal = Portal
  3. black screen when starting a game? copy shaders from half-life 2 (#350)
  4. need 32 bit build? add --32-bits to configure
  5. need debug? change -T release to -T debug

maksw2 avatar May 30 '24 09:05 maksw2

  • Make sure you uninstall visual studio 2022 and 2019
  • Install visual studio 2017, git and python 3

But it can be succesfully built by VS2022, why we need VS2017?

DiegoArmando-27 avatar Jun 24 '24 14:06 DiegoArmando-27

from what i've seen, vs2022 gives errors. did you really manage a succesfull vs2022 build? if yes, please share the details.

maksw2 avatar Jun 24 '24 19:06 maksw2

from what i've seen, vs2022 gives errors. did you really manage a succesfull vs2022 build? if yes, please share the details.

build.log config.log

DiegoArmando-27 avatar Jun 25 '24 04:06 DiegoArmando-27

that's very interesting... could it be because i was using vs 2022 proffesional? there were other people with the same problem - not being able to build with vs 2022. i've also seen a lot more warnings in your build.

maksw2 avatar Jun 25 '24 06:06 maksw2

i've also seen a lot more warnings in your build.

If my memory serves me, that warnings were even with VS2017 compilers

DiegoArmando-27 avatar Jun 25 '24 16:06 DiegoArmando-27

could it be because i was using vs 2022 professional?

Don't think that different types of VS provides different compilers

DiegoArmando-27 avatar Jun 25 '24 16:06 DiegoArmando-27

I have compiled CSS dedicated_server for Windows 32-bit, but I am unable to use metamod and sourcemod properly.SdkHooks and CStools cannot load properly, and many plugins cannot be used. Can you provide assistance in fixing this issue?

1922828151 avatar Jun 25 '24 17:06 1922828151

oh yeah, you might need to use an older version of these.

maksw2 avatar Jun 27 '24 08:06 maksw2

after i fixed my path and added a shit-ton of arguments it works?

maksw2 avatar Jun 28 '24 09:06 maksw2

updated it a bit

maksw2 avatar Jun 28 '24 09:06 maksw2

Any idea on how to build a solution file?

(nevermind, you need to use msvs to generate a VS2010 .sln)

Kizoky avatar Jul 16 '24 13:07 Kizoky

what? we use waf. vpc got replaced years ago.

maksw2 avatar Jul 17 '24 13:07 maksw2

VS2010

Nope. It generates solution for the last version of VS on your PC

DiegoArmando-27 avatar Jul 17 '24 15:07 DiegoArmando-27

what? we use waf. vpc got replaced years ago.

.\waf msvs to generate a Visual Studio Solution

DiegoArmando-27 avatar Jul 17 '24 15:07 DiegoArmando-27

what? we use waf. vpc got replaced years ago.

as much as I would like to admit waf is better, unfortunately it doesn't have intellisense

Kizoky avatar Jul 19 '24 12:07 Kizoky

it doesn't have intellisense

IntelliSense is Visual Studio, not waf or vpc

DiegoArmando-27 avatar Jul 20 '24 10:07 DiegoArmando-27

本指南将告诉您如何准备、编译和运行构建游戏。

  1. 安装 Visual Studio 2017 或 2022,附带 vs 2017 构建工具、git 或 github 桌面和 python 3
  2. 克隆 a. 使用 git 克隆:git clone https://github.com/nillerusr/source-engine.git --recursive b. 使用 github 桌面克隆。
  3. 进入命令提示符并运行以下命令: waf.bat configure -T release --prefix=hl2 --build-games=hl2 --disable-warns waf.bat build -p -v waf.bat install
  4. 现在你有一个名为“hl2”的目录,其中包含所有二进制文件
  5. 从你的 hl2 安装 (steam) 复制 hl2 和平台 (跳过覆盖文件) (如果你构建了任何其他游戏也请复制它的文件夹)
  6. 双击 hl2_launcher.exe

其他重要事项

  1. 想要语音聊天?在 configure 中添加 --enable-opus
  2. 更改构建游戏?在配置中更改 --prefix 和 --build-games hl1 = Half-Life 1: Source hl2 = Half-Life 2 // 默认 - 如果您不指定游戏,则会选择此项 episodic = Half-Life 2 Episode 1 ep2 = Half-Life 2 Episode 2 // 不要为 ep2 构建,而是使用 episodic。hl2mp = Half-Life 2: Deathmatch dod = Day of Defeat cstrike = Counter-Strike: Source portal = Portal
  3. 开始游戏时黑屏?从半条命 2 复制着色器(加载后黑屏 #350
  4. 需要 32 位版本?添加 --32-bits 进行配置
  5. 需要调试?将 -T release 改为 -T debug

After successfully building the project in Windows, is the hl2 directory the root directory? For example, my build directory is C:\Users\Administrator\source-engine, so the hl2 you mentioned is in the directory C:\Users\Administrator\source-engine\hl2, right? Then put the steam css file C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Source directly into C:\Users\Administrator\source-engine\hl2. If you encounter files with the same name, don't choose to replace them, right? I tried it and it kept giving me an error.

WZL203 avatar Sep 25 '24 14:09 WZL203

@WZL203 Let me clarify it. You build the entire engine. What you should do is grab platform, hl2 and in your case cstrike and copy it over to the build engine. Do not touch the bin folder! In WAF change --build-games to reflect your game. Make a new text file, give it the .bat extension, open it and type this: hl2_launcher.exe -game cstrike. Run it. If the screen is black copy the hl2 directory from Half-life 2, not Counter-strike. Hope it helps!

maksw2 avatar Sep 27 '24 05:09 maksw2

This is on Windows, using Steam assets from the "pre-anniversary update" branch.

Looks like hl2/resource files issue

Can you check if there's everything required is in your build?

DiegoArmando-27 avatar Nov 22 '24 15:11 DiegoArmando-27

I did copy everything in hl2. Maybe I need a different version of the game? But this engine is pretty new, I would expect it to work with the recent game, since there weren't any major updates before the 20th anniversary (and everything else in-game seems to work well).

VioletGiraffe avatar Nov 22 '24 16:11 VioletGiraffe

  1. black screen when starting a game? copy shaders from half-life 2 #350

This issue no longer appears to exist. Does anyone know how to do what this is referring to?

FlamedDogo99 avatar Nov 22 '24 21:11 FlamedDogo99

This issue no longer appears to exist. Does anyone know how to do what this is referring to?

In HL2:DM, there was a black screen in main menu. The fix is: just copy the hl2_misc_*.vpk files from vanilla HL2 to hl2/ directory

DiegoArmando-27 avatar Nov 23 '24 05:11 DiegoArmando-27

I did copy everything in hl2. Maybe I need a different version of the game? But this engine is pretty new, I would expect it to work with the recent game, since there weren't any major updates before the 20th anniversary (and everything else in-game seems to work well).

Pre-20th anniversary steam version is required.

since there weren't any major updates before the 20th anniversary

False. There's a rendering issues with new assets

DiegoArmando-27 avatar Nov 23 '24 05:11 DiegoArmando-27

Figured out my issue from before, it's because I didn't copy the platform folder - didn't read the instructions closely enough.

The same procedure works on Raspberry OS perfectly, you just have to figure out a couple dependencies to apt install as reported by the configure tool.

VioletGiraffe avatar Nov 23 '24 20:11 VioletGiraffe

  1. black screen when starting a game? copy shaders from half-life 2 black screen after loading #350

This issue no longer appears to exist. Does anyone know how to do what this is referring to?

@FlamedDogo99 i am the original creator of that Issue(tm) it was basically me trying to compile the engine but i got a pure black window due to lack of shaders this image is basically it image

but it was hl2

ThePixelMoon avatar Dec 01 '24 16:12 ThePixelMoon

when i try launching my built source engine i get this error when launching Image

Nekoarc123 avatar Aug 09 '25 19:08 Nekoarc123

when i try launching my built source engine i get this error when launching Image

what -game parameter did you add to hl2_launcher.exe?

maksw2 avatar Aug 10 '25 09:08 maksw2

when i try launching my built source engine i get this error when launching Image

what -game parameter did you add to hl2_launcher.exe?

Didn't try adding anything but will try adding -game hl2mp when i will be done building it again because i deleted it accidentally

Nekoarc123 avatar Aug 10 '25 11:08 Nekoarc123

when i try launching my built source engine i get this error when launching Image

what -game parameter did you add to hl2_launcher.exe?

Added the parameter didn't help

Nekoarc123 avatar Aug 10 '25 12:08 Nekoarc123

Can you translate the error?

maksw2 avatar Aug 10 '25 14:08 maksw2