Skip to content

Commit 7570d7f

Browse files
committed
Add VS2022 build instructions
1 parent 8561f24 commit 7570d7f

File tree

1 file changed

+81
-56
lines changed

1 file changed

+81
-56
lines changed

SourceCode/Builds/build_with_msvc22.md

Lines changed: 81 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,87 @@
1-
# Building and Compiling C&C Generals on Visual Studio 2022
1+
# Building and Compiling C&C Generals & Zero Hour on Visual Studio 2022
22

3-
## Prerequisites
4-
5-
1. **Install Visual Studio 2022**
6-
- Ensure that the necessary C++ development components, including MFC, are installed.
7-
8-
2. **Obtain the C&C Generals Source Code**
9-
- Clone or download the source code repository: [TheSuperHackers - GeneralsGameCode](https://github.com/TheSuperHackers/GeneralsGameCode.git).
10-
11-
3. **Install C&C Generals (Steam Version)**
12-
- The game installation is required to access the necessary asset files.
13-
14-
## Build Steps
15-
16-
### 1. Open the Project in Visual Studio 2022
17-
18-
- Launch Visual Studio 2022 and open the solution file `Code/RTS.sln`.
19-
20-
### 2. Select and Compile the Required Projects
21-
22-
- In the **Solution Explorer**, locate the following projects:
23-
- `RTS`
24-
- `WorldBuilder`
25-
- Right-click each project and select **Build**.
26-
- Ensure the build process completes without errors.
3+
This guide will walk you through the process of basic setup and compilation of the C&C Generals and Zero Hour source
4+
code using Visual Studio 2022.
5+
For build using solutions and more advanced build configurations, see below.
276

28-
### 3. Copy Required Game Files from Steam
29-
30-
- Navigate to your C&C Generals Steam installation directory, typically:
31-
32-
``` text
33-
C:\Program Files (x86)\Steam\steamapps\common\Command and Conquer Generals Zero Hour\
34-
```
35-
36-
- Copy all necessary `.BIG` files into the `Run` folder of your compiled project:
37-
38-
``` text
39-
EnglishZH.big
40-
INIZH.big
41-
SpeechZH.big
42-
W3DZH.big
43-
(Other required files)
44-
```
45-
46-
- Copy the entire `Data` folder to the `Run` folder as well.
47-
48-
### 4. Configure Paths Correctly
49-
50-
- Ensure that the `Run` folder within your build directory contains all required game assets.
51-
- If necessary, configure the **working directory** in Visual Studio:
52-
1. Right-click on the `RTS` project.
53-
2. Navigate to **Properties****Debugging**.
54-
3. Set `Working Directory` to your `Run` folder.
55-
56-
### 5. Run the Game or World Builder
7+
## Prerequisites
578

58-
- After compiling, navigate to the `Run` folder.
59-
- Launch `RTSD.exe` or `worldbuilder.exe`.
9+
1. **Visual Studio 2022**
10+
11+
- Ensure that the necessary C++ development components, **including MFC**, are installed.
12+
13+
>[!WARNING]
14+
> You must have the MFC components installed to compile the source code.
15+
<!-- markdownlint-disable-next-line -->
16+
2. **Obtain the Source Code (Step 1)**
17+
- Clone or download the source code
18+
repository: [TheSuperHackers - GeneralsGameCode](https://github.com/TheSuperHackers/GeneralsGameCode.git).
19+
20+
## Steps
21+
22+
### 1. Clone and prepare the project
23+
24+
- Clone the repository to your local machine.
25+
- Open the folder in Visual Studio 2022.
26+
- Wait for Visual Studio to generate the necessary cmake files.
27+
28+
### 2. Build the Project
29+
30+
- Select you favorite build configuration:
31+
- `Build Windows build` for a release build.
32+
- `Build Windows Debug build` for a debug build.
33+
- `Build Windows Internal build` for an internal build.
34+
- `Build Windows Profile build` for a profile build.
35+
36+
>[!TIP]
37+
> For more information on the different build configurations, see the [Build Configurations](build_configurations.md)
38+
page.
39+
40+
- Select the target you want to build:
41+
- `generalsv.exe` to build the base Generals.
42+
- `generalszh.exe` to build Zero Hour.
43+
44+
- Build the project by clicking on the `Build` menu and selecting `Build`.
45+
- The compiled executable will be placed in the `build/<win32 build type>/<game name (Generals/GeneralsMD)>/<build configuration>`
46+
folder. Example: `build/win32dgb/GeneralsMD/Debug`
47+
- Install the game executable in the game directory by clicking on the `Install` in `Build` menu. This will copy the
48+
executable to the retail game directory.
49+
50+
## Additional Steps
51+
52+
### Build through Cmake target view
53+
54+
- In the Solution Explorer, click on 'switch view' and select 'CMake Targets View'.
55+
- Expand the 'Genzh' project and right-click on the target you want to build.
56+
- Select 'Build' to compile the target.
57+
58+
### Build using command line
59+
60+
You need to install cmake and ninja to build the project from the command line.
61+
62+
- In the developer command prompt, open the settings to add the x86 environment terminal.
63+
64+
>[!Tip]
65+
> Alternatively, you can open the x86 Native Tools Command Prompt from the start menu, and navigate to the project
66+
directory in the terminal then run the commands below.
67+
68+
- In the pop-up window, click on the 'Add' and set the following: (assuming default installation path)
69+
- Name: `x86 Native Tools Command Prompt`
70+
- Shell Location: `C:\Windows\System32\cmd.exe`
71+
- Arguments: `/k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"`
72+
- Now you can open the new terminal from the terminal dropdown list.
73+
- Run the following commands to build the project:
74+
- Choose the build configuration:
75+
- `cmake --workflow --preset win32` for Release build.
76+
- `cmake --workflow --preset win32dgb` for Debug build.
77+
- `cmake --workflow --preset win32int` for Internal build.
78+
- `cmake --workflow --preset win32prof` for Profile build.
79+
- Install the game executable in the game directory (assuming that the build was successful):
80+
- `cmake --install build/<preset name>`
81+
- To build a specific target:
82+
- Run `cmake --build build/<preset name> --target <target name>`
83+
- Example: `cmake --build build/win32 --target z_generals`
84+
- Or: `cmake --build build/win32 --target g_generals`
6085

6186
## Troubleshooting
6287

0 commit comments

Comments
 (0)