-
Notifications
You must be signed in to change notification settings - Fork 60
build_with_msvc22
This guide will walk you through the process of basic setup and compilation of the C&C Generals and Zero Hour source code using Visual Studio 2022. For build using solutions and more advanced build configurations, see below.
- Prerequisites
- Build through Visual Studio 2022
- Build through CMake target view
- Build using command line
- Build using solutions
- Troubleshooting
- Visual Studio 2022
- Ensure that the necessary C++ development components, including MFC, are installed.
Note
You must have the MFC components installed to compile the source code. You can find it in Visual Studio Installer.
-
Obtain the Source Code
- Clone or download the source code repository: TheSuperHackers - GeneralsGameCode.
- Open the cloned folder in Visual Studio 2022.
- Wait for Visual Studio to generate the necessary CMake files.
- Select the appropriate build configuration:
-
Build Windows build
for a release build. -
Build Windows Debug build
for a debug build. -
Build Windows Internal build
for an internal build. -
Build Windows Profile build
for a profile build.
-
Tip
For more information on the different build configurations, see the Build Configurations page.
- Select the target you want to build:
-
generalsv.exe
to build the base Generals. -
generalszh.exe
to build Zero Hour.
-
- Build the project by clicking on the
Build
menu and selectingBuild
. - The compiled executable will be placed in the build folder. Example:
build/win32dgb/GeneralsMD/Debug
- Install the game executable in the game directory by clicking on the
Install
inBuild
menu. This will copy the executable to the retail game directory.
- In the Solution Explorer, click on 'switch view' and select 'CMake Targets View'.
- Expand the 'Genzh' project and right-click on the target you want to build.
- Select 'Build' to compile the target.
You need to install CMake and Ninja to build the project from the command line.
- In the developer command prompt, open the settings to add the x86 environment terminal.
- In the pop-up window, click on the 'Add' and set the following: (assuming default installation path)
- Name:
x86 Native Tools Command Prompt
- Shell Location:
C:\Windows\System32\cmd.exe
- Arguments:
/k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"
- Name:
- Now you can open the new terminal from the terminal dropdown list.
Tip
Alternatively, you can skip the terminal setup and simply open the "x86 Native Tools Command Prompt for VS 2022" from the Start menu. Once opened, navigate to the project directory in the terminal and proceed to run the commands below.
-
-
Choose the build configuration:
-
cmake --workflow --preset win32
for Release build.
-
-
Install the game executable in the game directory (assuming the build was successful):
cmake --install build/win32 --config Release
-
-
-
Choose the build configuration:
-
cmake --workflow --preset win32dgb
for Debug build. -
cmake --workflow --preset win32int
for Internal build. -
cmake --workflow --preset win32prof
for Profile build.
-
-
Install the game executable in the game directory (assuming the build was successful):
cmake --install build/<preset name>
-
-
To build a specific target:
- Run
cmake --build build/<preset name> --target <target name>
- Example:
cmake --build build/win32dgb --target z_generals
- Or:
cmake --build build/win32int --target g_generals
- Run
For more CMake options, see the CMake Guide.
- Generate the Visual Studio solution with the appropriate preset (see above):
- Run
cmake --preset win32 -G "Visual Studio 17 2022" -A Win32
- Navigate to the
build/win32
folder and open the generated solution file. - Build the project using the Visual Studio interface.
- Missing DLLs? Ensure that all required dependencies are installed.
-
Game not launching? Verify that all necessary
.BIG
files are correctly placed. -
Build errors? Check Visual Studio settings and dependencies for any issues or delete the
build
folder and try building again.
- How to Get Involved
- How to Contribution
- Community forks
- License
- Credits
- Changelog
- FAQ
- Known Issues
- Contact & Community
-
Visual Studio 6 Guides:
-
Visual Studio 2022 Guides:
- DirectX
- STLport
- Max4SDK
- NVASM
- Benchmark
- MilesSoundSystem
- Bink
- SafeDisk
- Asimp3
- GameSpy
- ZLib
- LZHCompress