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

How to compile the DLL

Discussion in 'Civ5 - SDK / LUA' started by DaveMcW, Nov 2, 2012.

  1. Anvil

    Anvil Chieftain

    Joined:
    Nov 4, 2009
    Messages:
    18
    OH so I edit the files in visual C++, build and put the new dll in the root of my modbuddy mod. Got ya thanks.
    :)
     
  2. Drawmeus

    Drawmeus Emperor

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    Whoward - I can honestly say that if it weren't for your contributions on this forum (several other people as well, believe me I recognize what people here are doing for me! but especially whoward) - I would have almost no chance at successfully pulling off the mod I'm doing.
     
  3. Genghis.Khan

    Genghis.Khan Person

    Joined:
    Jun 9, 2012
    Messages:
    934
    Location:
    Somewhere
  4. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,656
    Location:
    France
    The DLL is build from all files, they should already been included in the project file.
     
  5. Genghis.Khan

    Genghis.Khan Person

    Joined:
    Jun 9, 2012
    Messages:
    934
    Location:
    Somewhere
  6. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,656
    Location:
    France
    I've added the update fix (thanks whoward69 !) to the first post.

    @DaveMcW: feel free to edit if needed, of course.
     
  7. Airny

    Airny Warlord

    Joined:
    Aug 6, 2006
    Messages:
    297
    Location:
    Germany
    Wow, this worked immediately for me (just had to remove the 0kb files manually) and I have my first mod running!
    Changing the C++ code is much easier for me than working with the lua or xml.

    Can I assume that any mod that has no dll in its folder doesn't change the dll?
    Then there is no problem to use this mod with others, I guess.
     
  8. Drawmeus

    Drawmeus Emperor

    Joined:
    Jul 25, 2007
    Messages:
    1,213
    If it doesn't include a dll, it doesn't change the dll.

    There are lots of ways you can have compatibility problems, but the most common are probably: two mods with dlls are automatically not compatible, and you can only use one mod that changes a given UI element at a time (e.g. only one mod can change how the TopPanel works at a time).
     
  9. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,524
    Location:
    Near Portsmouth, UK
    Just finished ripping what little hair I've got left out.

    If you want to use VS-2010 to build the DLL (which I was) you need to install VS-2008 FIRST and then VS-2010 (installing VS-2008 after VS-2010 because you forgot to do it doesn't seem to work!)
     
  10. fufie

    fufie Peanut Farmer

    Joined:
    Jan 3, 2013
    Messages:
    118
    Location:
    Norway
    The VS 2008 Express downloads have been removed. Will try to see if the vc90 sp1 will let me install things, if not it is debugging template code for the lua references.
     
  11. DaveMcW

    DaveMcW Deity

    Joined:
    Oct 8, 2002
    Messages:
    6,489
    Download link is fixed.
     
  12. fufie

    fufie Peanut Farmer

    Joined:
    Jan 3, 2013
    Messages:
    118
    Location:
    Norway
    Thanks, the new download link worked great :)
     
  13. S3rgeus

    S3rgeus Emperor

    Joined:
    Apr 10, 2011
    Messages:
    1,270
    Location:
    London, United Kingdom
    I'm having some difficulty deploying a new DLL mod. After some coercing, it is loading my custom DLL, but the game crashes immediately. (Between hitting "Next" on the mod selection screen and when the sound effect plays for the button press, which is, I would think, when the mod is loaded.) Attempting to find this error, I've stripped out basically all of my code. (Commented out) The only changes (that git diff can see and I can remember) are the two "afrxes.h" -> "windows.h" and I've created a new GUID using the VS2010 GUID creator and added it to CvDllContext.cpp (replacing the old GUID).

    I get the following, lone error in the GameCore.log file:

    [49977.509] GetProcAddress('DllGetGameContext') failed with error 127: The specified procedure could not be found.


    I've looked at that function (DllGetGameContext), and it's definitely still there. It's all got me a bit stumped.
     
  14. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,524
    Location:
    Near Portsmouth, UK
    The DLL MUST have the correct name "CvGameCore_Expansion1.dll" - note that the default name from the build is NOT correct. The DLL MUST be in the root of the mod (and not a sub-folder). The DLL MUST only have VFS=true - do not try to use the GetDLLEntry stuff in ModBuddy as it's broken.

    If that doesn't fix it, try using a copy of the standard dll in your mod (ie replacing the dll with itself) - if you still get crashes you've probably got a permissions error and Windoze doesn't want to execute code from your user (sub-)directory.
     
  15. S3rgeus

    S3rgeus Emperor

    Joined:
    Apr 10, 2011
    Messages:
    1,270
    Location:
    London, United Kingdom
    Very good suggestions, I hadn't thought of the windows permissions issues. But I'm still stuck, unfortunately. I've rolled back to the only changes are now the "afrxes.h" headers in the .rc files and the GUID in CvDllContext.cpp and it still crashes on load. The mod only has one other file, which is a lua script that runs when the map loads, but that never runs before the crash.

    Oddly enough, the mod does work if I include the standard expansion dll, so it doesn't seem to be a permissions problem.

    EDIT: I've also tried it without the GUID change (using the default one) and that gives me the same crash.

    EDIT 2: Fixed! Turns out I hadn't done the vcproj file changes from the first post properly. :mischief:
     
  16. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,524
    Location:
    Near Portsmouth, UK
    Don't forget to put the GUID change back in
     
  17. S3rgeus

    S3rgeus Emperor

    Joined:
    Apr 10, 2011
    Messages:
    1,270
    Location:
    London, United Kingdom
    Yep, I've put that back. I had some fun with some binary files being committed to git by accident and Visual Studio didn't much like them changing without its supervision.

    Now I'm off to poke around and see if I can induce a terrain graphics refresh without reloading the whole game.
     
  18. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,524
    Location:
    Near Portsmouth, UK
    A number of us will be very grateful if you can! Search for "layoutdirty" in CvPlot.cpp
     
  19. primordial stew

    primordial stew Emperor

    Joined:
    Sep 1, 2005
    Messages:
    1,219
    Location:
    a puddle
    How do we get a "debug" DLL? In civ4 there was a different makefile for it. Here though I've not seen anything about it.

    Following the directions in the 1st post I generated a CvGameCore_Expansion1.dll and CvGameCore_Expansion1.pdb. I added them to my mod (at the level below the mod name), with the dll having VFS = true, but I haven't set the pds with the same. Using "Visual Studio 9.0" "attach to process" it can stop on the CtDs, but I don't get any Asserts (civ4 had quite a few usually), and then the failure is almost always outside of the symbols territory, so there isn't even any source code to look at to help figure out where things are going wrong.

    What else is there to this?

    Debug dll, you're my only hope! That is unless someone can explain how to start a game. Really what I'd like to do is to load a .civ5map file that contains only terrain, and specify everything else in Lua files, but I can't figure out how to load a .civ5map and then a lua file to set the civs/unit/cities. Instead then I've created a "map script" which loads a Lua file which contains the base map, and then overrides the other map script functions (eg AddGoodies, GenerateTerrain, AddRivers, StartPlotSystem, AddFeatures, DetermineContinents, GeneratePlotTypes, GetMapScriptInfo, and GetMapInitData). Prior to the map script the lua file containing the PreGame settings is loaded (ala MedievalScenarioLoadScreen.lua). The game CtDs during Events.SerialEventStartGame(), but I've no idea why. The lua.log shows that my code has run, and that my civs are alive, so that part all looks clean. Still though, CtD!
     
  20. ls612

    ls612 Deity Moderator

    Joined:
    Mar 10, 2008
    Messages:
    8,073
    Location:
    America
    The new DLL compiles fine out of the box with the exception that you need to replace the afxres.h with windows.h in the resource file. Everything else seems to work correctly now in the build.

    Edit: It also looks like the requirement to make a GUID has been removed.
     

Share This Page