Chazcon
Prince
Yes, you CAN use the free Microsoft Visual C++ 2005 Express Edition (albeit not right out of the box) to mod Civilization IV’s CvGameCoreDLL.dll code that is publicly available from Firaxis in the SDK.
Credit goes to DaveMcW, Kael, and Maian for doing all the hard work. I’ve only combined their efforts into one post.
*** I’ve changed this procedure slightly so that it makes sense for both vanilla and Warlords code ***
Let’s do it:
1 - *VANILLA*
Download the SDK from Civilization IV Source Code. This is a file named Civ4_SDK_source.zip. Unzip it and you will see the following directory structure:
(folder you extracted it to)
CvGameCoreDLL_v161
CvGameCoreDLL
Boost-1.32.0
Python24
I suggest that you leave these folders and their files in place and intact so that you always have an original copy of the source files. Copy the folder CvGameCoreDLL and all of it’s contents to another location (commonly called your working folder).
DELETE two files, CvGameCoreDLL.vcproj, and CvGameCoreDLL.vcproj.vspcc.
1 - *WARLORDS*
Install Warlords, and patch 2.08. You will see a folder in your \Warlords directory named CvGameCoreDLL. I suggest that you leave this folder and it’s files in place and intact so that you always have an original copy of the source files. Copy the folder CvGameCoreDLL and all of it’s contents to another location (commonly called your working folder).
DELETE two files, CvGameCoreDLL.vcproj, and CvGameCoreDLL.vcproj.vspcc.
2 - Download and install Microsoft Visual C++ Toolkit 2003.
3 - Download the following three library files and put them in the folder:
C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib
msvcrt.lib
msvcrtd.lib
msvcprt.lib
4 - Download and install the Microsoft Platform SDK.
5 - Download the Makefile and extract it into your CvGameCoreDLL_v161\CvGameCoreDLL folder.
6 - Open the Makefile in WordPad (not Notepad).
At the very top, change the line that begins with TOOLKIT to the path of your Visual C++ Toolkit 2003 directory.
Change the line that begins with PSDK to the path of your Microsoft Platform SDK.
Save and exit.
7 - Download and install Microsoft Visual C++ 2005 Express Edition
8 - Launch Visual C++ 2005 Express Edition
*** DO NOT open the existing project file in Visual C++ 2005 Express Edition ***
9 - Click -File- -New- -Project-. The ‘New Project’ window will open.
In the ‘Project types’ box select –General-.
In the ‘Templates’ box select -Makefile Project-.
In the ‘Name’ box type ‘CvGameCoreDLL’.
In the ‘Location’ box browse to the folder where you copied your CvGameCoreDLL folder to. This folder MUST be the last folder listed in this box. For example, if you copied CvGameCoreDLL to another folder like so:
C:\MyModsFolder\CvGameCoreDLL
The entry in the ‘Location’ box must read:
C:\MyModsFolder
UNCHECK the box that says 'Create Directory for Solution'.
Click -OK-. The ‘Makefile Application Wizard’ will open. Click –Next-. Clear all the boxes. Click –Finish-.
10 - Click -Project- -Add Existing Item…-. The ‘Add Existing Item - CvGameCoreDLL’ window will open.
This folder will contain all of the source code files, the Boost-1.32.0 folder, and the Python24 folder. Select everything (use Ctrl-A) and click -Add-.
11 - Click -Project- -CvgameCoreDLL Properties-. The ‘CvgameCoreDLL Properties Pages’ window will open.
In the left-hand box under ‘Configuration Properties’ select ‘NMake’.
In the upper-right-hand corner click the ‘Configuration Manager’ button. The ‘Configuration Manager’ window will open.
In the upper-left-hand box named ‘Active solution configuration’, click the drop-down button and select ‘<Edit…>’. The ‘Edit Solution Configurations’ window will open.
Select ‘Debug’ and click the ‘Remove' button. Click 'Yes'.
Select ‘Release’ and click the ‘Rename’ button. Change the name from ‘Release’ to ‘Final_Release’. Click 'Rename'. Click 'Yes'.
Close the ‘Edit Solution Configurations’ window.
In the ‘Project contexts’ window, in the ‘Configurations’ column, click the drop-down button and select ‘<Edit…>’. The ‘Edit Project Configurations’ window will open. Repeat the steps above to remove ‘Debug’ and rename ‘Release’ to ‘Final_Release’.
Close the ‘Configuration Manager’ window. Now you’re back at the ‘CvgameCoreDLL Properties Pages’ window. Make sure in the left-hand box under ‘Configuration Properties’ you’ve selected ‘NMake’.
In the right-hand box under ‘General’ it says ‘Build Command Line’. Click the empty box to the right of it and type ‘nmake Final_Release’.
In the next line down, to the right of where it says ‘Rebuild All Command Line’, click in the empty box and then click the button in the box at the right. The ‘Rebuild All Command Line’ window will open. Type ‘nmake clean Final_Release’, and then directly below it on a second line, type ‘nmake Final_Release’. Click -OK-.
In the next line down, to the right of where it says ‘Clean Command Line’, type ‘nmake clean Final_Release’.
Click 'Ok' to close the ‘CvgameCoreDLL Properties Pages’ window,
*** YOU ARE DONE ***
Now, the first thing to do is to compile the source code. Click -Build- -Build Solution-. This will begin building, or compiling, the source code. It takes about 20 minutes to do a full compile on my machine.
When the build has completed successfully, you will see this in the last few lines of the ‘Output’ box:
------------------------------------------------------------------------------------------------------
LINK : warning LNK4089: all references to 'KERNEL32.dll' discarded by /OPT:REF
CvGameCoreDLL - 0 error(s), 1 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
------------------------------------------------------------------------------------------------------
You can ignore the harmless LNK4089 warning. Any other warnings should be addressed (errors in your code after you’ve been modding).
A successful build will generate the folder ‘Final_Release’ which is under your CvGameCoreDLL folder like so:
CvGameCoreDLL_v161
CvGameCoreDLL
Boost-1.32.0
Final_Release
Python24
In the ‘Final_Release’ folder you will find your freshly baked CvGameCoreDLL.dll file, which you then copy into your mod’s Assets folder.
*** MODDING ***
After you go into the source code and modify it, you’ll need to compile the code, to produce a modified CvGameCoreDLL.dll file. The nice thing is, you’ll only need to compile the files you have changed, so it’s much faster to do a build after changing a couple of files. If you’re like me, you’ll be building .dll’s and testing them regularly. If you’re a REAL programmer, I’d imagine you’d have a good grasp of what code works and what doesn’t just by looking at it. For us novices, the compiler itself will teach you a few things through the errors and warnings it produces when you compile. C++ isn’t easy at first, but there are a lot of resources available on the web and at your local bookstore. One of my favorite links: cplusplus.com. Getting into detail about C++, modding, and best practices are beyond the scope of this post.
Have fun!
Credit goes to DaveMcW, Kael, and Maian for doing all the hard work. I’ve only combined their efforts into one post.
*** I’ve changed this procedure slightly so that it makes sense for both vanilla and Warlords code ***
Let’s do it:
1 - *VANILLA*
Download the SDK from Civilization IV Source Code. This is a file named Civ4_SDK_source.zip. Unzip it and you will see the following directory structure:
(folder you extracted it to)
CvGameCoreDLL_v161
CvGameCoreDLL
Boost-1.32.0
Python24
I suggest that you leave these folders and their files in place and intact so that you always have an original copy of the source files. Copy the folder CvGameCoreDLL and all of it’s contents to another location (commonly called your working folder).
DELETE two files, CvGameCoreDLL.vcproj, and CvGameCoreDLL.vcproj.vspcc.
1 - *WARLORDS*
Install Warlords, and patch 2.08. You will see a folder in your \Warlords directory named CvGameCoreDLL. I suggest that you leave this folder and it’s files in place and intact so that you always have an original copy of the source files. Copy the folder CvGameCoreDLL and all of it’s contents to another location (commonly called your working folder).
DELETE two files, CvGameCoreDLL.vcproj, and CvGameCoreDLL.vcproj.vspcc.
2 - Download and install Microsoft Visual C++ Toolkit 2003.
3 - Download the following three library files and put them in the folder:
C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib
msvcrt.lib
msvcrtd.lib
msvcprt.lib
4 - Download and install the Microsoft Platform SDK.
5 - Download the Makefile and extract it into your CvGameCoreDLL_v161\CvGameCoreDLL folder.
6 - Open the Makefile in WordPad (not Notepad).
At the very top, change the line that begins with TOOLKIT to the path of your Visual C++ Toolkit 2003 directory.
Change the line that begins with PSDK to the path of your Microsoft Platform SDK.
Save and exit.
7 - Download and install Microsoft Visual C++ 2005 Express Edition
8 - Launch Visual C++ 2005 Express Edition
*** DO NOT open the existing project file in Visual C++ 2005 Express Edition ***
9 - Click -File- -New- -Project-. The ‘New Project’ window will open.
In the ‘Project types’ box select –General-.
In the ‘Templates’ box select -Makefile Project-.
In the ‘Name’ box type ‘CvGameCoreDLL’.
In the ‘Location’ box browse to the folder where you copied your CvGameCoreDLL folder to. This folder MUST be the last folder listed in this box. For example, if you copied CvGameCoreDLL to another folder like so:
C:\MyModsFolder\CvGameCoreDLL
The entry in the ‘Location’ box must read:
C:\MyModsFolder
UNCHECK the box that says 'Create Directory for Solution'.
Click -OK-. The ‘Makefile Application Wizard’ will open. Click –Next-. Clear all the boxes. Click –Finish-.
10 - Click -Project- -Add Existing Item…-. The ‘Add Existing Item - CvGameCoreDLL’ window will open.
This folder will contain all of the source code files, the Boost-1.32.0 folder, and the Python24 folder. Select everything (use Ctrl-A) and click -Add-.
11 - Click -Project- -CvgameCoreDLL Properties-. The ‘CvgameCoreDLL Properties Pages’ window will open.
In the left-hand box under ‘Configuration Properties’ select ‘NMake’.
In the upper-right-hand corner click the ‘Configuration Manager’ button. The ‘Configuration Manager’ window will open.
In the upper-left-hand box named ‘Active solution configuration’, click the drop-down button and select ‘<Edit…>’. The ‘Edit Solution Configurations’ window will open.
Select ‘Debug’ and click the ‘Remove' button. Click 'Yes'.
Select ‘Release’ and click the ‘Rename’ button. Change the name from ‘Release’ to ‘Final_Release’. Click 'Rename'. Click 'Yes'.
Close the ‘Edit Solution Configurations’ window.
In the ‘Project contexts’ window, in the ‘Configurations’ column, click the drop-down button and select ‘<Edit…>’. The ‘Edit Project Configurations’ window will open. Repeat the steps above to remove ‘Debug’ and rename ‘Release’ to ‘Final_Release’.
Close the ‘Configuration Manager’ window. Now you’re back at the ‘CvgameCoreDLL Properties Pages’ window. Make sure in the left-hand box under ‘Configuration Properties’ you’ve selected ‘NMake’.
In the right-hand box under ‘General’ it says ‘Build Command Line’. Click the empty box to the right of it and type ‘nmake Final_Release’.
In the next line down, to the right of where it says ‘Rebuild All Command Line’, click in the empty box and then click the button in the box at the right. The ‘Rebuild All Command Line’ window will open. Type ‘nmake clean Final_Release’, and then directly below it on a second line, type ‘nmake Final_Release’. Click -OK-.
In the next line down, to the right of where it says ‘Clean Command Line’, type ‘nmake clean Final_Release’.
Click 'Ok' to close the ‘CvgameCoreDLL Properties Pages’ window,
*** YOU ARE DONE ***
Now, the first thing to do is to compile the source code. Click -Build- -Build Solution-. This will begin building, or compiling, the source code. It takes about 20 minutes to do a full compile on my machine.
When the build has completed successfully, you will see this in the last few lines of the ‘Output’ box:
------------------------------------------------------------------------------------------------------
LINK : warning LNK4089: all references to 'KERNEL32.dll' discarded by /OPT:REF
CvGameCoreDLL - 0 error(s), 1 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
------------------------------------------------------------------------------------------------------
You can ignore the harmless LNK4089 warning. Any other warnings should be addressed (errors in your code after you’ve been modding).
A successful build will generate the folder ‘Final_Release’ which is under your CvGameCoreDLL folder like so:
CvGameCoreDLL_v161
CvGameCoreDLL
Boost-1.32.0
Final_Release
Python24
In the ‘Final_Release’ folder you will find your freshly baked CvGameCoreDLL.dll file, which you then copy into your mod’s Assets folder.
*** MODDING ***
After you go into the source code and modify it, you’ll need to compile the code, to produce a modified CvGameCoreDLL.dll file. The nice thing is, you’ll only need to compile the files you have changed, so it’s much faster to do a build after changing a couple of files. If you’re like me, you’ll be building .dll’s and testing them regularly. If you’re a REAL programmer, I’d imagine you’d have a good grasp of what code works and what doesn’t just by looking at it. For us novices, the compiler itself will teach you a few things through the errors and warnings it produces when you compile. C++ isn’t easy at first, but there are a lot of resources available on the web and at your local bookstore. One of my favorite links: cplusplus.com. Getting into detail about C++, modding, and best practices are beyond the scope of this post.
Have fun!