In my opinion, it has always been too complicated to set up your system to compile a new DLL for your BtS mod. There are of course great guides on that out there (I want to give a special shout out to asaf's guide that I used to follow), but they still require you to piece together everything from multiple different sources and were in part outdated and not making use of the contributions of other modders since their creations.
I also realised that with Civ4 further aging, it is becoming harder and harder to recreate its development environment, which is getting progressively out of date and obscure. I think we've been in real danger of download links expiring and becoming unavailable.
Also apparently not all distributions of BtS come with the DLL sources. I don't think it should be hard to find those sources.
So I went on to bundle everything you need to set up a DLL compiler from scratch in as few places as possible. This collection is a bit opinionated, for example I settled on Visual Studio and Nightinggale's makefile, but it should run out of the box. Here's the components:
1) A git repository containing the DLL source, all external dependencies (Python and Boost libraries), a Makefile, and a preconfigured project/solution for Visual Studio
2) An ISO file to install Visual Studio 2010 Express
3) An Install Wizard to install the Windows SDK and Visual C++ toolkit
Prerequisites
To download the sources from Github, I suggest you use git, which you can install from here. I suggest using Github Desktop as your git client, which is easy and intuitive to use. In general it is always worth it to familiarise yourself with git as a developer, because even though it initially seems complex and challenging, it really makes your life easier in many ways. You can still download the git repository without installing git, however.
If you want to install Visual Studio from my ISO file, you need a program to mount ISOs. I recommend using the free Daemon Tools Lite.
Setup from Scratch
1) Install the Windows SDK and Visual C++ toolkit
Download the Install Wizard and run it, following the instructions. It will try to install by default to <Program Files>\Civ4SDK\, whatever the name and drive of your primary program files folder is (e.g. C:\Program Files (x86)\). If you choose a different location, please keep note of it for later.
2) Install Visual Studio 2010 Express
Download the ISO File, mount and run it. The installation will also offer to install other tools, but you only need Visual Studio 2010 Express.
3) Get the source code, Makefile and project setup
If you are using git, run "git clone https://github.com/dguenms/beyond-the-sword-sdk.git". Alternatively, you can download it as a ZIP archive from here.
You are downloading the CvGameCoreDLL folder for your new mod. Conventionally, you would put this folder next to the Assets folder in your mod directory, i.e. in Beyond the Sword\Mods\MyMod, and it is preconfigured assuming you do so. Theoretically, you can put it wherever on your computer though.
Depending on your previous choices, you might have to adjust the Makefile in the following ways:
- if you chose a different location during step 1, you have to change lines 34-35 so the TOOLKIT and PSDK variables point to the right locations (remove $(PROGRAMFILES)\Civ4SDK\, and replace it with your chosen location)
- if you did not put the CvGameCoreDLL folder inside your mod directory, put a path to your mod directory into the YOURMOD variable in line 37
4) Launch your project in Visual Studio
Double click on the CvGameCoreDLL.sln file, it should open in Visual Studio with an already configured project.
To test if everything is working, run Build ... -> Rebuild Solution.
Integrating with Git
If you are familiar with Git, you can fork from the BtS SDK source repository right away before cloning it. This way you can commit all your changes as your mod develops, and have everything under source control.
Future Plans
I have several ideas about how to go from here, including:
1) Follow Nightinggale's instructions about optimising file headers for faster compilation time.
2) Set up a build server for the source repo. I think I can configure it in such a way that whenever you create a pull request against the repo, it will build the DLL based on those sources and upload it somewhere. This would actually enable people to run builds without ever setting up a compiler on their system.
Acknowledgements
asaf for his comprehensive DLL modding guide, which I reverse engineered and condensed here
Nightinggale for the included Makefile
I also realised that with Civ4 further aging, it is becoming harder and harder to recreate its development environment, which is getting progressively out of date and obscure. I think we've been in real danger of download links expiring and becoming unavailable.
Also apparently not all distributions of BtS come with the DLL sources. I don't think it should be hard to find those sources.
So I went on to bundle everything you need to set up a DLL compiler from scratch in as few places as possible. This collection is a bit opinionated, for example I settled on Visual Studio and Nightinggale's makefile, but it should run out of the box. Here's the components:
1) A git repository containing the DLL source, all external dependencies (Python and Boost libraries), a Makefile, and a preconfigured project/solution for Visual Studio
2) An ISO file to install Visual Studio 2010 Express
3) An Install Wizard to install the Windows SDK and Visual C++ toolkit
Prerequisites
To download the sources from Github, I suggest you use git, which you can install from here. I suggest using Github Desktop as your git client, which is easy and intuitive to use. In general it is always worth it to familiarise yourself with git as a developer, because even though it initially seems complex and challenging, it really makes your life easier in many ways. You can still download the git repository without installing git, however.
If you want to install Visual Studio from my ISO file, you need a program to mount ISOs. I recommend using the free Daemon Tools Lite.
Setup from Scratch
1) Install the Windows SDK and Visual C++ toolkit
Download the Install Wizard and run it, following the instructions. It will try to install by default to <Program Files>\Civ4SDK\, whatever the name and drive of your primary program files folder is (e.g. C:\Program Files (x86)\). If you choose a different location, please keep note of it for later.
2) Install Visual Studio 2010 Express
Download the ISO File, mount and run it. The installation will also offer to install other tools, but you only need Visual Studio 2010 Express.
3) Get the source code, Makefile and project setup
If you are using git, run "git clone https://github.com/dguenms/beyond-the-sword-sdk.git". Alternatively, you can download it as a ZIP archive from here.
You are downloading the CvGameCoreDLL folder for your new mod. Conventionally, you would put this folder next to the Assets folder in your mod directory, i.e. in Beyond the Sword\Mods\MyMod, and it is preconfigured assuming you do so. Theoretically, you can put it wherever on your computer though.
Depending on your previous choices, you might have to adjust the Makefile in the following ways:
- if you chose a different location during step 1, you have to change lines 34-35 so the TOOLKIT and PSDK variables point to the right locations (remove $(PROGRAMFILES)\Civ4SDK\, and replace it with your chosen location)
- if you did not put the CvGameCoreDLL folder inside your mod directory, put a path to your mod directory into the YOURMOD variable in line 37
4) Launch your project in Visual Studio
Double click on the CvGameCoreDLL.sln file, it should open in Visual Studio with an already configured project.
To test if everything is working, run Build ... -> Rebuild Solution.
Integrating with Git
If you are familiar with Git, you can fork from the BtS SDK source repository right away before cloning it. This way you can commit all your changes as your mod develops, and have everything under source control.
Future Plans
I have several ideas about how to go from here, including:
1) Follow Nightinggale's instructions about optimising file headers for faster compilation time.
2) Set up a build server for the source repo. I think I can configure it in such a way that whenever you create a pull request against the repo, it will build the DLL based on those sources and upload it somewhere. This would actually enable people to run builds without ever setting up a compiler on their system.
Acknowledgements
asaf for his comprehensive DLL modding guide, which I reverse engineered and condensed here
Nightinggale for the included Makefile
Last edited: