1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[BTS] The Easiest Way to Compile a New DLL

Discussion in 'Civ4 - SDK/Python' started by Leoreth, Dec 29, 2016.

  1. DarkLunaPhantom

    DarkLunaPhantom Prince Supporter

    Joined:
    Feb 4, 2013
    Messages:
    424
    Is there a Windows.h file in your ...\Civ4SDK\WindowsSDK\include folder?
     
  2. EdmundIronside

    EdmundIronside Prince

    Joined:
    Jun 27, 2017
    Messages:
    388
    Gender:
    Male
    Location:
    Grand Rapids, MI.
    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

    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:
     
  3. EdmundIronside

    EdmundIronside Prince

    Joined:
    Jun 27, 2017
    Messages:
    388
    Gender:
    Male
    Location:
    Grand Rapids, MI.
    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!
     
  4. billw2015

    billw2015 King

    Joined:
    Jun 22, 2015
    Messages:
    837
    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
     

    Attached Files:

    • deps.7z
      File size:
      12.9 MB
      Views:
      29
  5. KaTiON_PT

    KaTiON_PT Emperor

    Joined:
    Jan 2, 2010
    Messages:
    1,090
    Location:
    Portugal
    @Leoreth is it possible to mention this archive in your thread? :)
     
    MattCA likes this.
  6. citis

    citis Deity

    Joined:
    Jul 8, 2011
    Messages:
    2,480
    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.
     
    Leoreth likes this.
  7. 1SDAN

    1SDAN Brother Lady

    Joined:
    Oct 27, 2014
    Messages:
    2,555
    Is it possible to compile the DLL on Linux?
     
  8. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,348
    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.
     
    1SDAN likes this.
  9. bluepotato

    bluepotato Warlord

    Joined:
    Dec 11, 2018
    Messages:
    189
    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.

    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.
     
    1SDAN likes this.
  10. Nightinggale

    Nightinggale Deity

    Joined:
    Feb 2, 2009
    Messages:
    4,348
    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.
     
  11. bluepotato

    bluepotato Warlord

    Joined:
    Dec 11, 2018
    Messages:
    189
    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.
    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: Feb 24, 2020
  12. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,722
    Gender:
    Male
    Location:
    Leblanc
    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.
     
  13. bluepotato

    bluepotato Warlord

    Joined:
    Dec 11, 2018
    Messages:
    189
    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.
     
  14. 1SDAN

    1SDAN Brother Lady

    Joined:
    Oct 27, 2014
    Messages:
    2,555
    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.
     
  15. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,722
    Gender:
    Male
    Location:
    Leblanc
    I know it's meant as a compliment to Wine but it's also quite the drag on Windows.
     
    Nightinggale, 1SDAN and bluepotato like this.
  16. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,747
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Get a good OS. Install WinXp :D
     
  17. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,722
    Gender:
    Male
    Location:
    Leblanc
    I would have gladly stayed with Win7 if I could but Microsoft had other things in mind.
     
  18. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,747
    Gender:
    Male
    Location:
    In a constant brainstorm...
    I'm still on Win7 and not planing to change.
    Resistance is NOT futile.
    :sniper:____________________________ :assimilate:
     

Share This Page