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

[SDK] Colonization Makefile

Discussion in 'Civ4Col - Mods and Files' started by alpaca, Oct 6, 2008.

  1. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    For those of you who'd like to use the SDK with Visual C++ 2005/2008 Express, here's a version of the Civ4 makefile edited to work with Colonization. Thanks to the guys who created the makefile and figured out how to set this stuff up for Civ4.

    To install simply unrar the makefile to your SDK folder, then open the makefile and do the necessary path changes. The two batch files provide support for forward slashes in the del command, I use them to be able to clean the project. If you want to use it, too, extract the two files to your CvGameCoreDLL directory and point the "rm=" line in the makefile to the rmf.bat file.

    Version 1.1 supports debugging. Extract the included cpp files along with the makefile to your CvGameCoreDLL folder and proceed as usual. Thanks to Refar for his cleaned-up version of the Civ4 makefile

    Also see this thread for details on how to set up the SDK with VC++ Express: http://forums.civfanatics.com/showthread.php?t=196283

    Note that I didn't test this extensively, it compiles fine and I started a game with it, so I guess it should work. I'm a noob when it comes to this stuff though, so maybe I forgot something important ;)
     

    Attached Files:

  2. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    Uploaded new version with debugging available and fixed the batch file.
     
  3. historix69

    historix69 Emperor

    Joined:
    Sep 30, 2008
    Messages:
    1,242
    1. I followed the description from the link above and used the Makefile, but I was not very successful.
    - There were some open references because two or three files were missing in the makefile. I added them ...
    - Finally I got a DLL and could load it in Col2, but most of the pages in Civilopedia were empty and when I started a new game, the complete world was only grasland except for the starting tile which was Seaway to Europe. The UserInterface was gone, too ... and the game would crash during 1st AI-turn.

    2. Second Experiment was also not successfull. I had copied all sourcefiles from the cvGameCoreDLL to a new folder and had tried to convert the cvGameCoreDLL-project (Version VSC++ v7.1.0) into VisualStudio 2008 ... I had to change some code were type-declarations in the header of for-loops were missing. When I got the DLL compiled, it would not load ... Game would crash during load around setting up uncached XML or Python ...

    3. I found the solution in the CIV4-SDK-Forum-Discussion (Link) how to compile the SDK. I already had installed most of the tools from the 1st experiment and with CodeBlocks and some small additional changes (removing debug-flags) I was successful, at least what I can tell from starting a short game and doing some turns. Everything looked normal after loading my freshly compiled dll.
     
  4. Belizan

    Belizan Emperor

    Joined:
    Jan 11, 2006
    Messages:
    1,060
    Not to be a necrophile or what have you, but, after several hours of tinkering with this, I thought I'd post for clarification. In order to compile the CvGameCoreDLL.dll am I actually required to use the older 7.1 libraries, VC++ compiler and outdated PSDK? The PSDK link from the referenced thread is for a windows2003 version of the SDK... I don't even know which versions of the CRT libs those are.

    Anyway, I tried to modernize on my own, and ran into the same bizarre XML init and null reference errors as historix using my 2008 converted version of the project (with the /Zc:scope- tweak). I recall seeing somewhere someone saying that the Boost libs were compiled against 7.1 and so incompatibilities would arise if one failed to compile against the same.

    Anyway, after a few wasted hours debugging that (the problem arises outside of the debuggable scope), I decided to get Voodoo and follow the exact instructions from the referenced thread with the makefile Alpaca provided.

    This didn't work either. As Historix pointed out, there are two files "missing" from the makefile (CyMapInterface.cpp and MyGameInterface.cpp). These files are actually present, broken up into multiple files (a pattern which repeats itself with other files as well). The problem is CvDLLPython.cpp is completely unaware of these object name changes, and so the makefile won't link as is. If you fix it, it will link and run, but it is.. buggy. I haven't had the chance to verify, but I think it's probably because a lot of functions are "lost" from other Cy classes because of the way these other Python wrapper objects were broken up into multiple files. I'll test that later.

    What's the story with all this? We really have to compile against these older libs with an older compiler? Also, what's up with CvTextScreens.cpp? It references files that don't exist :/. Is it really safe to leave out? Anyone know?

    I know Melinko seems to have a working version of the Col SDK, as does, I suppose Dale et al. Maybe one of them can clarify for me 8). Here's hoping ;)
     
  5. Dale

    Dale Deity

    Joined:
    Mar 14, 2002
    Messages:
    7,017
    I use visual studio 2003 (alongside my 2005 as well). ;)

    That's what Civ4 was originally programmed in so I just use the existing proj file, switch to "Final Release" and hit compile. 10 mins later I have a DLL. Then I start editing. :)
     
  6. Belizan

    Belizan Emperor

    Joined:
    Jan 11, 2006
    Messages:
    1,060
    I think I have a version of VS2003 around. Does it install with all the libs required for the SDK, or do I need to install some other old tech? 8).

    BTW, while I'm posting, I meant to ask above, but spaced, why did those various files (CyMapInterface.cpp for example) get broken up into multiple files? It doesn't seem to serve any purpose that I could see.
     
  7. Dale

    Dale Deity

    Joined:
    Mar 14, 2002
    Messages:
    7,017
    Probably from the team perspective it made it easier. X works on file A while Y works on file B and Z works on file C.

    Dunno. :)

    You might need to install some MS SDK, not sure. I installed onto Vista which already has the requirements and can't remember what I did in XP to get it working (was 3 and a half years ago now :p). I'm pretty certain you'll have to install the latest DirectX SDK and put the directory in your system path statement.
     
  8. Belizan

    Belizan Emperor

    Joined:
    Jan 11, 2006
    Messages:
    1,060
    I just got done testing it. Installed with Vis Studio .Net 2003 (VS7) and it worked like a charm. Of course, I already have the PSDK installed, but I don't think that it knows where it is.

    As an added bonus I also, simultaneously, got the makefile version to work :/. For bonus redundency. Ah well. The VS7 version is much faster though. And gets intellisense. Mmmm...

    Still not sure why Firaxis left out CvTextScreens.cpp from the project but included it in the sdk source, but so far it's working without it so all good, I suppose 8).

    BTW, Dale, to clarfiy the splitting up of source files I was asking about, I meant the separating done by someone involved in creating the makefile. For some reason, they split some of the Cy Python wrapper files into multiple source files (each defining a wrapper object with a different name, herein being the bug). For instance CyMapInterface.cpp into CyMapInterface1.cpp and CyMapInterface2.cpp. That was the change which I didn't understand the need for. I still don't, btw. But it *does* cause the resultant DLL to malfunction. Changing it back, and patching the makefile fixed the problem.
     
  9. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    Sorry mate, I screwed up the archive by forgetting to include DvDLLPython.cpp - you're of course right, it has to be made aware of the changes to the other files. Note that if you don't want to debug, you don't need to use the files in the archive.

    Edit: First point updated. I split the python interface files because the compiler gave me an error when trying to make a debug build (some size limit was exceeded, I forgot the exact error message). I found a post in the Civ4 forums that claims this is caused by too many python definitions in a single interface file, so I split them up which fixed the problem for me.
    Besides, Firaxis split up some of them, too.
     
  10. feckhornet

    feckhornet Chieftain

    Joined:
    Dec 12, 2005
    Messages:
    8
    After much head scratching and trying to piece together everybody's advice I've managed to get a build working in VS2008.

    I used the PDF instructions for BTS 3.17 to set up VS2008, grabbed the makefile from Alpaca and then had to remove the files: CyMapInterface.cpp and CyGameInterface.cpp from my vcc project.

    thanks to all who have written advice on how to do this. Would be good to get this thread stickied on the CivIV:Col forum page so that it's easy to find for newbie modders. It's taken me ages to track down all the information I needed to get things working.
     
  11. feckhornet

    feckhornet Chieftain

    Joined:
    Dec 12, 2005
    Messages:
    8
    I have now successfully build dlls for release and debug. I've also attached to the debug dll whilst running the game so I can now debug.

    One thing to note is that the makefile does not appear to rebuild .cpp files when one of the .h files they reference is changed. This coupled with the fact that you cannot build/rebuild individual .cpp files makes editing .h files a pain. You basically have to change the .cpp file so that that file is rebuild with the updated .h file. Of course you also have to know which .cpp files include the .h file you are editing. I know nothing about makefiles, but if someone who does can fix this issue it would be a great help.
     
  12. Jean Elcard

    Jean Elcard The Flavournator

    Joined:
    Feb 26, 2006
    Messages:
    1,008
    Location:
    Leipzig, Germany
    Splitting the interface files up did the trick for me too. The exact error message is (with VC++ 2008 Express):

    Spoiler :
    Code:
    fatal error C1067: compiler limit : debug information module size exceeded
    ~~~~~~~~~~~~

    My solution is ussually to rebuild the whole project if I make changes to header files. If I don't do this, I get a lot of strange errors later on. On my machine this takes 10 minutes. That's ok for me.

    Maybe this would work too. Just read it in Refars manual, but didn't try it:

    Spoiler :
     
  13. feckhornet

    feckhornet Chieftain

    Joined:
    Dec 12, 2005
    Messages:
    8
    sure, but you'd still have to do that for each file that included a header you had changed. it's a pain to have to work this out each time you change a header. my compile is about 15-20 mins which is too long to do very often, especially as i like to keep my debug and release up to date.

    thanks for the suggestion though.
     
  14. Refar

    Refar Deity

    Joined:
    Apr 10, 2005
    Messages:
    4,608
    There is no such thing as "Rebuild a single file". To get a updated DLL you need to rebuild the project, no matter if you updated a single .h file or not. If you skip "Clean", some of the old files - presumably the ones un-affected by the change - will get used without recompiling. Unfortunately it's not allways foolproof.

    Compiling single files (as opposed to building the whole project) was mentioned, because it is a lot faster and might be useful as a quick check, before proceeding with the more time consuming build, i.e. for beginners, who might be prone for simple (syntax) mistakes.
     
  15. feckhornet

    feckhornet Chieftain

    Joined:
    Dec 12, 2005
    Messages:
    8
    the problem is that files affected by a change to a .h file do not always get picked up in a build. that's the only reason i can see for needing a rebuild. if there was some way of mapping these dependencies (a simple script would do) then you could simply make a change to all the affected .cpp files using a script. This would update their last modified timestamps and then they would get picked up in the build.

    I've done this by hand a couple of times and it appears to work. It's possible that you would only need to open and save the unchanged .cpp files for the build to pick them up as having changed, but I'm not sure.
     
  16. ADHansa

    ADHansa Warlord

    Joined:
    Jan 26, 2006
    Messages:
    149
    I am simply lost.
    I am not sure what instructions to follow from the link and where to deviate.
    1 guess it is point 1, 5 and 10 that i should do differently, but i can not figure out what to do.
    Anybody that know what works and care to explain it?
     
  17. Refar

    Refar Deity

    Joined:
    Apr 10, 2005
    Messages:
    4,608
    I am not sure what "point 1, 5 and 10" are, that you are talking about :mischief: ... Anyway...

    What you need is to follow the instructions for compiling the Civ4 Bts SDK (PDF in my Signature) to the letter, but use the files Alpaca provided in the first post instead of the Makefile in the archive.
     
  18. ADHansa

    ADHansa Warlord

    Joined:
    Jan 26, 2006
    Messages:
    149
    I tried to follow the instructions to the letter but in some places it didn't make sence to me. I tried to do what i thought was most logic in those occasions but finally i couldn't get it to work anyway. Here are the "points" where i don't get what to do.

    - this one
    Spoiler :
    1 - *VANILLA*
    Download the SDK from Civilization IV Source Code. This is a file named Civ4_SDK_source.zip. Unzip it and you will see the following directory structure:

    (folder you extracted it to)
    CvGameCoreDLL_v161
    CvGameCoreDLL
    Boost-1.32.0
    Python24

    I suggest that you leave these folders and their files in place and intact so that you always have an original copy of the source files. Copy the folder CvGameCoreDLL and all of it’s contents to another location (commonly called your working folder).

    DELETE two files, CvGameCoreDLL.vcproj, and CvGameCoreDLL.vcproj.vspcc.


    1 - *WARLORDS*
    Install Warlords, and patch 2.08. You will see a folder in your \Warlords directory named CvGameCoreDLL. I suggest that you leave this folder and it’s files in place and intact so that you always have an original copy of the source files. Copy the folder CvGameCoreDLL and all of it’s contents to another location (commonly called your working folder).

    DELETE two files, CvGameCoreDLL.vcproj, and CvGameCoreDLL.vcproj.vspcc.



    and this one

    Spoiler :


    5 - Download the Makefile and extract it into your CvGameCoreDLL_v161\CvGameCoreDLL folder.




    and finally this

    Spoiler :


    10 - Click -Project- -Add Existing Item…-. The ‘Add Existing Item - CvGameCoreDLL’ window will open.

    This folder will contain all of the source code files, the Boost-1.32.0 folder, and the Python24 folder. Select everything (use Ctrl-A) and click -Add-.

     
  19. Refar

    Refar Deity

    Joined:
    Apr 10, 2005
    Messages:
    4,608
    I see. Unfortunately these do make sense - with the exception of the Vanilla/Warlords refererences, which you should correspondingly read as "Colonization".

    Also the instructions you quoted are very old.
    They are still valid in general, but there is a clarified/updated version in the most recent PDF, that i (again ;)) suggest to use. It also has screenshots, that might help you find the interface elements you seem to be missing.

    If the instructions talk about Makefile you use the Makefile + Supplementary files that Alpaca provided. If some of the files, that you are supposed to delete are missing, you can skip deleting and move on to the next step ;)

    Edit: Also if you stuck completely, try just calling nmake from the command line (There is a section in the PDF with exact syntax). This way you can skip setting up a project, if that causes trouble for you (but you still need the compiler installed).
     
  20. ADHansa

    ADHansa Warlord

    Joined:
    Jan 26, 2006
    Messages:
    149
    I had a second go it and this time it seems to go better. Not really sure what i made different.
     

Share This Page