[BTS] The Easiest Way to Compile a New DLL

Hi @devolution
I tried removing the second statement, but sadly I still got the same error.

This is the path where I have the SDK:
C:\Program Files (x86)\Civ4SDK\WindowsSDK

Is there a Windows.h file in your ...\Civ4SDK\WindowsSDK\include folder?
Yes the windows.h file is there. Here is the path where I find it:
C:\Program Files (x86)\Civ4SDK\WindowsSDK\include

The strange thing is I was able to compile the dll on my old laptop.
When it stopped working I got this new computer, installed all the different components again, but now am getting this problem.
I'm not sure what changed when I reinstalled everything on this computer. :confused:
 
In case anyone ever has the same issue as me, here is how I 'resolved' the issue:
I downloaded Nightinggale's Makefile 2.5 pack and used that instead of my makefile.
Other than needing to delete the CvTextScreens file from the dll due to an error involving not finding the cvtxtmgr file, that seems to have fixed the issue!
 
Here is an archive containing ALL dependencies required to build the DLL.
If you extract it to a directory it will create a deps directory under it that looks like this:
upload_2019-8-1_0-11-38.png
 

Attachments

  • deps.7z
    12.9 MB · Views: 221
Great guide!
I only encountered two problems:
* You have to check the paths at the start of the makefile.
* It might not work in PC with non latin encoding. I had to copy and past from Github.
 
Is it possible to compile the DLL on Linux?
Apparently yes because somebody has managed to do so and written about it somewhere on the forum. I imagine using a portable compiler (as in just the files. It doesn't actually have to be installed) together with wine would be the way to go. Visual Studio is essentially just a GUI for what is a makefile based project, meaning you can get away with compiling from command line if you really want to do so. Status of debugger in linux is unknown or untested.
 
Is it possible to compile the DLL on Linux?
Yes, but the compiler crashes on wine versions above 1.7 so you'll need to get that. I downloaded it with PlayOnLinux and used it from the command line because PlayOnLinux's GUI didn't really work for me. Visual Studio doesn't work either, so you either have to get CodeBlocks (which was really slow for some reason, took like 45 minutes to compile the whole thing) or set up nmake manually.
Now the latter is a lot more complicated as it seems, because a) makefiles crash at seemingly random locations and b) they don't usually find all proper paths. I managed to hack together a solution for RFGW in the end, which only works with Danny Daemonic's Makefile 1.0 but at least you don't have to wait ages for it to actually compile. It worked for almost every single DLL I've tried so far, except DoC which needed psapi.lib - solution is, assuming your setup is identical to mine, to add
Code:
psapi.lib /LIBPATH:"Z:$HOME/.wine_versions/linux-amd64/1.7.55/lib/wine/fakedlls/"
to the end of both link.exe calls.
This shell script can be found here, and I don't think I really changed anything in the Makefile. It's in the repository, anyways.

Status of debugger in linux is unknown or untested.
cdb doesn't start at all. winedbg does, but you need to start the process with winedbg instead of wine, attaching to it will crash the game. You can supposedly set breakpoints with it, but so far I haven't had any luck finding out how.
 
which only works with Danny Daemonic's Makefile 1.0
This is most likely a limitation of your script rather than an issue with Makefile 2.5 or wine. Granted Makefile 2.5 is more complex to call because the makefile needs to be called multiple times with different targets. The reason for this is target dependency limitations in nmake. Yes it's bad, but it's the best I can do with nmake and the only way to add support for using more than one CPU core to compile. For some reason nmake doesn't even have multi core support natively.

Since WTP (develop branch) now relies on a perl script (autogenerated header) and strawberry perl comes with GNU make, rewriting the makefile to the GNU standard has become an option. This would fix a lot of the issues and makefile weirdness. However for the time being if it ain't broke, don't fix it.
 
This is most likely a limitation of your script
Not really, my script is just a hack to make the process at least finish. Ideally there wouldn't be a need for the script at all, but nmake doesn't seem to work all that great on wine... especially on wine 1.7. Do mind that we're talking about a more than 5-year-old development version.
The good thing about makefile 1.0 is that it "only" crashes at the linking stage (because of path problems). So I just copied the link call CodeBlocks's log showed, modified it to use the same options as the makefile is supposed to, added some paths and it magically worked. It'd definitely be better if I could fix the Makefile itself, but I don't really know how it works.
In contrast, your makefile shows some syntaxt error while removing old obj files, which could still be caused by path problems but I wouldn't know how to fix it. Interestingly it seems to work better on the latest wine 5 version (meaning it did at least start compiling)... problem is, using any wine version above wine 2 results in an internal compiler error (both using makefiles and codeblocks), which is definitely a limitation of wine.
Since WTP (develop branch) now relies on a perl script (autogenerated header) and strawberry perl comes with GNU make, rewriting the makefile to the GNU standard has become an option. This would fix a lot of the issues and makefile weirdness. However for the time being if it ain't broke, don't fix it.
Sounds interesting, but I'm currently happy with my solution too :) Trying to compile code using an ancient version of VC++ on Linux has proven to be a great way to waste time, time I'd rather spend coding.
 
Last edited:
Isn't there an affordable way to get your hands on a Windows virtual machine? Or even set one up using the Windows license you're already using on your Windows installation? I'd love to develop my stuff on my Linux machine but all the cross compatibility issues aren't worth it. I wish you could just spin up a clean Windows environment.
 
Isn't there an affordable way to get your hands on a Windows virtual machine? Or even set one up using the Windows license you're already using on your Windows installation? I'd love to develop my stuff on my Linux machine but all the cross compatibility issues aren't worth it. I wish you could just spin up a clean Windows environment.
That just depends on how far you're willing to go to avoid using Windows. Playing civ on a virtual machine does sound painful though, I feel like it'd be even harder to set up than wine+nmake.
And surprisingly civ 4 is about as compatible with win10 as with wine. Fullscreen mode works even better from what I can tell... though that also depends on the desktop environment you use. The only problems I've run into so far is that one CtD in your mod and the lack of user-friendly debuggers.
 
Isn't there an affordable way to get your hands on a Windows virtual machine? Or even set one up using the Windows license you're already using on your Windows installation? I'd love to develop my stuff on my Linux machine but all the cross compatibility issues aren't worth it. I wish you could just spin up a clean Windows environment.
I can't get Virtualbox to run.
upload_2020-2-25_3-34-55.png
It gives this error.
upload_2020-2-25_3-35-58.png
Which then leads to this error.

I've been trying to figure out how to get gparted live to boot from USB so I can dual boot Windows, but it returns error 22.

I've been getting so many errors and crashes playing DoC on Linux that I've stopped reporting them since the Bug Reports thread would just end up with entire pages of me.
 
And surprisingly civ 4 is about as compatible with win10 as with wine.
I know it's meant as a compliment to Wine but it's also quite the drag on Windows.
 
I would have gladly stayed with Win7 if I could but Microsoft had other things in mind.
 
I know this is an old thread, but are any changes needed to make this guide work for Civ4Col (other than obviously a new .sln and the Civ4Col .dll source)?
 
I know this is an old thread, but are any changes needed to make this guide work for Civ4Col (other than obviously a new .sln and the Civ4Col .dll source)?
It still works, but if you want to mod Civ4Col, then you should be in touch with the WTP team. Either you want to join the team or you want to make something else, in which case you should start from the WTP mod because it has years' worth of bugfixes and optimization.
 
Last edited:
Top Bottom