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. FramedArchitect

    FramedArchitect Reluctant Modder

    Joined:
    Mar 25, 2012
    Messages:
    798
    Location:
    Missouri
    Building Expansion 2 dll without any changes at all results in quite a few reported errors in "output" tab. I got a lot of references like this

    Code:
    FireWorksWin32.lib(FAutoVariableBase.obj) : warning LNK4099:
    
    Is this normal?
     
  2. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,526
    Location:
    Near Portsmouth, UK
  3. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    For Windows 7 folks, there is a reported incompatibility with VS-2008(sp1). If you see pages and pages of "...unexpected precompiled header error, simply rerunning the compiler might fix this problem", you might have discovered this. (No, recompiling doesn't fix the problem.) The link above does provide a hotfix for VS-2008(sp1), if you want to try that.

    What I did instead was install VS-2010. Keep in mind whoward69's warning:
    Since I had followed the OP's instructions, I already had VS-2008(sp1) installed. So I went ahead and installed VS-2010 (download Visual C++ 2010 Express here). I copied CvGameCoreSource to the new appropriate folder (/My Documents/Visual Studio 2010/Projects). Redid steps 6 - 12 (open CvGameCoreDLL.vs2010.sln now). Moved CvGameCore_Expansion2.dll to test mod with VFS=true. Tested. Works.

    It's a much nicer interface than VS-2008, anyway, especially if you are already used to it from Modbuddy.


    By the way, is there any reason not to change the linker output to go directly to the Modbuddy project folder? It would save me from one drag-and-drop operation, which wouldn't be so bad... [Edit: This is what I do now and it seems fine. Just build in VS-2010, then build in Modbuddy ... and done. No moving files around.]
     
  4. ExpiredReign

    ExpiredReign Deity

    Joined:
    Jan 3, 2013
    Messages:
    2,450
    Gender:
    Male
    Location:
    Tasmania
    Ok, so after a long time of looking on and wondering what it would be like to do some DLL modding I decided to bite the bullet and try. Here's what I did.

    I have been tinkering with programming on and off for many years but never really as anything more than a curiosity, so I already had a working installation of Visual Studio 2010 from the Windows 7.1 SDK iso. I had been able to follow sample code and tutorials so felt sure I could get into this.

    First step. Read all the posts.
    This thread is full of info about the necessity to have VS 2008 so I was fully expecting to install that at some point.

    Step two. Testing the water.
    I setup the Civ V SDK as outlined here and made the needed changes to a stock DLL source and see what messages I get back, just to make sure VS 2008 is needed.
    It is.

    Step three. Install VS 2008.
    Now this is where the fun starts. The installation file starts and I am greeted with the message here: (right click and load image in a new tab)

    Apparently I already have VS2008 and just need to install SP1.​

    Ok, I can do that. Off to the download page again for the SP1 install. This time the installation file starts and gives me this error:

    C'mon Microsoft, either I have VS 2008 or I don't, which is it?​

    Step four. Minor hiccup.
    "No problem", I say to myself, "just uninstall ALL Visual Studio software and start again." A minute or two later I have uninstalled and start the process again.
    Same messages again. Apparently I still have an earlier un-updated install on my system.

    Step five. Regedit.
    So thinking there may be some orphaned references to VS left in the registry I uninstall any software remotely linked to VS 2008, restart Windows and then purge the registry of any mention of Visual Studio, 2008, Silverlight or anything else I can think might be linked to VS 2008. Retry the setup software again and... you guessed it, I still have something in my system that tells MS I have Visual Studio 2008 installed.

    Step six. A rethink.
    Clearly I am having a Sisyphus moment if I think I can tackle that problem with that strategy. How else can I get to playing with the source code? So I look at the ways the compiler would be set up to look for VS 2008 and that's when it hits me I need a bit of outside input.
    What I can imagine is the project either is looking for a specific version of the tools needed to compile the source, maybe linker or assembler or it is looking for specific system files that may somehow be used. (not really sure of the 2nd option)
    So I was thinking, what if I created a new VS 2010 project and use the source files to build a DLL?
    • Would it work with the executables in the Civ directory?
    • Would there be a version mismatch between them or possibly just not do anything?
    • In short, is there a way to circumvent the need to have VS 2008 installed?

    My immediate answer to those questions is NO! I am not going to be able to work with DLL modding unless I do a complete reformat and reinstall of my system. (that aint gonna happen)

    Any ideas? Give up now and be content with xml/sql/lua edits?
     
  5. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,526
    Location:
    Near Portsmouth, UK
    Probably the .net frameworks, try removing 4.5 and 4 (IIRC 3 and before where pre-2010)
     
  6. ExpiredReign

    ExpiredReign Deity

    Joined:
    Jan 3, 2013
    Messages:
    2,450
    Gender:
    Male
    Location:
    Tasmania
    Regrettably no success. :(

    Ah well, looks like I will have to convince my wife I need a new computer. :D
    Or not. At least I can still do some of the simpler tasks to do with modding.
    Thanks.
     
  7. UltimatePotato

    UltimatePotato Chieftain

    Joined:
    Jul 6, 2014
    Messages:
    24
    Location:
    United Kingdom
    Quoted for truth. I haven't tried using 2010 though, I'm too extatic from getting 2008 to work at all :crazyeye:
     
  8. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,526
    Location:
    Near Portsmouth, UK
    Anybody got this working with VS-2013?

    When I install VS-2013 it either removes or hides the VS-2008 toolset and also uninstalls VS-2010, so the project no longer builds. If you "upgrade" the project to VS-2013 format (and hence tools) it will compile but now generates hundreds, if not thousands of warnings about unused parameters/variables and potentially un-initialised variables - making it completely impossible to find "real" errors.

    I have neither the time nor inclination to fix all the warnings - presumably there is some #pragma warning(disable:) magic that would switch these warnings off

    Fortunately, uninstalling VS-2013 and repairing VS-2010 reverted to a position where the project builds - phew!
     
  9. S3rgeus

    S3rgeus Emperor

    Joined:
    Apr 10, 2011
    Messages:
    1,270
    Location:
    London, United Kingdom
    This is a good warning, I was planning on installing VS2013 soon. Isn't there an option in VS2013 to not show warnings in the errors window like in 2008/10/12? I've found that the Firaxis code warnings make trying to view any unhelpful (unfortunately, because they can pick up helpful stuff), but you still get errors separately.
     
  10. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,526
    Location:
    Near Portsmouth, UK
    Possibly, but Visual Studio is not my forte, so I was hoping someone else could work it out ;)

    There weren't that many with VS-2008/10 - a few unused parameters and some things which should have been _noop - that it was easy enough to mod the source to remove them.

    But in VS-2013 there were pages and pages and pages of them - easier to revert to VS-2010 than spend time and effort fighting with an environment I only use for fun
     
  11. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    They dropped macros in VS2012/2013. (Ducks and runs while Whoward69's head explodes...)

    Or was this a different kind of "macro" than the macro I'm thinking about that we use all the time?
     
  12. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,526
    Location:
    Near Portsmouth, UK
    Different macros
     
  13. Harald B

    Harald B Warlord

    Joined:
    Oct 20, 2010
    Messages:
    135
    A small note about this since it had me confused for a moment: I'm not sure if this was always the case, but the code mentioned above is now located not in CvDllContext.cpp but in CvDllVersion.h.
     
  14. biship

    biship Warlord

    Joined:
    Dec 7, 2003
    Messages:
    187
    What I had to do to get this working in VS2013:

    Installed VS2008
    Successfully compiled DLL in VS2008
    Installed VS2013
    Opened the 2010 solution in VS2013, got the ""Visual Studio 2008 (v90) Not Installed" Error.
    (I did not upgrade the 2010 solution to a 2013 solution)
    Installed \Setup\vc_stdx86.exe from GRMSDKX_EN_DVD.iso
    (from http://stackoverflow.com/questions/33173296/building-vc-2008-project-with-vs-2013)

    Now the 2010 solution compiles successfully in VS2013.

    I tried the vc_stdx86.exe trick with VS2015, which solved the "v90 Not Installed" error. However immediately on Build, I get an error I could not solve. (So I use VS2013, and not VS2015).

    Code:
    1>------ Build started: Project: CvGameCoreDLL, Configuration: Mod Win32 ------
    2>------ Build started: Project: CvGameCoreDLL_Expansion1, Configuration: Mod Win32 ------
    3>------ Build started: Project: CvGameCoreDLL_Expansion2, Configuration: Mod Win32 ------
    1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(57,5): error : Required file "" is missing.
    2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(57,5): error : Required file "" is missing.
    3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(57,5): error : Required file "" is missing.
    ========== Build: 0 succeeded, 3 failed, 0 up-to-date, 0 skipped ==========
    (Thanks for the help from whoward69)
     
  15. gia

    gia Chieftain

    Joined:
    Sep 30, 2013
    Messages:
    60
  16. S3rgeus

    S3rgeus Emperor

    Joined:
    Apr 10, 2011
    Messages:
    1,270
    Location:
    London, United Kingdom
    Isn't Express the free edition of VS? I didn't think that required registration to work. The ones that cost money (Professional/Ultimate) might do.
     
  17. gia

    gia Chieftain

    Joined:
    Sep 30, 2013
    Messages:
    60
    I don't know MS's convoluted process by heart, but the simple setup I used did, and the registration page is no longer online since its vs2008, so it stopped working on the 30th day, and what people suggested was that I fully uninstalled (to remove whatever registry kept track of my expired trial) and used the pre-registered ISO instead, which if you download, wont compile the dll because it doesnt have SP1, and the SP1 update only applies to the paid version, so you have to uninstall again and find the ISO of Express with SP1 already patched in...

    I was also told that I had to first uninstall all newer versions of visual studio I had installed on top, or the thing would probably not work and would remember my lack of activation, after I had 2008 working I could reinstall newer versions on top of it.

    For some reason I remember uninstalling the 2010 shell that you must use for the Civ SDK, not sure it was actually necessary or just me trying everything to make things work...

    I don't get any trial messages now and can compile, so I think it works.
     
  18. wartedkiller

    wartedkiller Chieftain

    Joined:
    Jul 13, 2016
    Messages:
    1
    So I'va downloaded VS 2008 from the link and followed the instruction to load the project. When I try to compile, I have the error

    LINK : fatal error LNK1104: cannot open file '\CvGameCoreDLLWin32Mod.dll'

    What do I do from here?
     
  19. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,526
    Location:
    Near Portsmouth, UK
    Going to need more info.

    Where are you trying to compile the code from - the SDK location or have you copied the source code from the SDK location into the "My Documents" (typically "C:\Users\{username}\Documents\Visual Studio 2008\Projects") area?
     
  20. frutiemax

    frutiemax Chieftain

    Joined:
    Jan 19, 2015
    Messages:
    54

Share This Page