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

A simple guide to compiling the DLL

Discussion in 'Civ4 - Modding Tutorials & Reference' started by Asaf, Dec 29, 2010.

  1. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326

    Overview

    This tutorial is intended to be a simple step-by-step guide to compiling the DLL.

    This tutorial does not teach C++, or how to edit the Civ4 C++ source code. For these you might try one of these C++ tutorials and Xienwolf's An Idiots Guide to Editing the DLL.
    My tutorial covers the 'Setting up the SDK' section of Xienwolf's tutorial.

    I tried bringing the required installations to a minimum, so I packed parts of the previously installed components in archives which only need to be extracted, to prevent problems with 64-bit OS's. I also included only some of the parts of the original components, since most of it was not needed.

    All archives are in .7z format, which can be extracted using 7-zip (which is free) or WinRAR (which is not).

    The makefile+fastdep utility credit goes to DannyDaemonic (Downloaded from here),
    with some modifications to the makefile which I added.

    I put in spoiler tags extra information which is not necessary for the process, but might help you understand it better.

    Spoiler :

    A short introduction (feel free to skip)
    Unlike Python source files, which are interpreted at runtime (and therefore don't need to go through any kind of processing beforehand), C++ source files need to be converted to machine language (commands which are comprised of 1's and 0's). This process is called compilation.

    The final product of the compilation process (and some other processes which we'll not go into) of Civ4's C++ code is a DLL file (Dynamically Linked Library). The game loads this file and uses the code which was generated in the compilation.


    How to prepare the compilation environment

    This tutorial will help you prepare the environment to convert the C++ source code files to a DLL which the game can use.

    Let's get to it!

    Step 1: Download and install Microsoft Visual C++ 2008 Express (thanks to embryodead for uploading it). You might need to restart your system afterwards.
    This is the only component you actually need to install.

    Admittedly, you don't have to use it (there are alternatives), but it makes life somewhat easier, so I suggest you do.

    Spoiler :

    Microsoft Visual Studio is an IDE (Integrated Development Environment) which allows you to edit, compile and debug your code.
    Visual C++ is the component of Visual Studio for handling C++ code.

    The current version of VS is 2010, but there were rumors that the 2010 Express edition lacks somewhat in the field of debugging, so I used 2008.


    If you want to use VS2010, here's an explanation from Sareln on what you have to change:
    The Express edition is the free version of Visual Studio. Apparently you need to register it (for free) to use it more than 30 days.

    And thanks to embryodead for the following tip:
    Note: The previous download is an online installer (it's an installer which downloads the actual application installer). If you want an offline installer, check out the spoiler below.
    Spoiler :

    According to the instructions in this link, you can download this file from microsoft and extract it to a folder.
    Then you need to go to the command line in this folder and run:
    Code:
    msiexec /i vs_setup.msi vsextui=1 addlocal=all reboot=reallysuppress
    
    And thanks to civjo for testing it and for bringing up this issue.


    Step 2: Download the packed Microsoft Visual C++ Toolkit 2003, and extract it where you see fit.
    Remember the path of the extracted folder, since you'll need it later on. The archive size is ~5MB, and the extracted folder is ~32MB.

    Spoiler :

    This toolkit contains several tools and files which are needed to compile the source code. Specifically it contains the compiler and linker utilities.
    In addition it contains header files (e.g. the STL header files) and libraries (e.g. the basic C++ runtime libraries) which match the version in which the game was originally compiled, and that is to make the DLL compatible with the game's executable (that's why we use an old version of this toolkit).


    Step 3: Download the packed Windows Platform SDK and extract it where you see fit.
    Again, you'll need this path later on. The archive size is ~10MB, and the extracted folder is ~110MB.

    Spoiler :

    This archive contains some of the files of the Windows Platform SDK (version 6). Specifically it contains the resource compiler (to embed the version information), and all the include and lib files for x86 architecture (which is what the DLL is compiled to).
    This SDK contains the basic Windows environment modules, which (almost) every program which compiles to Windows environment needs.
    It also contains many unneeded things, but it seemed like a bad idea to try to filter them by functionality.


    Step 4: Download the project and makefile archive, and extract it in the folder in which you want to keep your mod's source files.

    Spoiler :

    Extracting it will create the CvGameCoreDLL folder, in which you'll have the following files:

    CvGameCoreDLL.sln - The 'solution' file for your C++ project. This file is the file you double-click to open the Visual C++ environment (or just open it from inside the VC++). The solution points to the project file (each solution can contains one or more projects. This solution contains just one).

    CvGameCoreDLL.vcproj - The project file for you C++ project. This project holds a list of files that you can see in the file tree (solution explorer) in your Visual C++, and holds the parameters to send to the Makefile.

    bin folder - Holds the fastdep utility which creates the dependency structure between source and header files.

    Makefile - This file contains the actual instructions of what to build, and how to build it.


    Step 5: Edit the Makefile (extracted to CvGameCoreDLL folder).
    You can open this file in any text editor (Visual Studio will also do), and update the following paths:

    Code:
    #### Paths ####
    TOOLKIT=C:\Dev\Microsoft Visual C++ Toolkit 2003
    PSDK=C:\Dev\WindowsSDK
    CIVINSTALL=D:\games\Civilization IV\Beyond the Sword
    
    TOOLKIT is the path where you extracted Microsoft Visual C++ Toolkit 2003 (step 2).
    PSDK is the path you extracted Windows Platform SDK (Step 3).
    CIVINSTALL is your BTS installation path.

    Checkout the spoiler tag to enable auto-copying the DLL to where it should be:
    Spoiler :

    You can also edit the following line to copy the finished DLL directly to you assets folder after it is compiled successfully (To uncomment delete the '#' at the beginning of the line with YOURMOD=):

    Code:
    ## Uncomment to have newly compiled dlls copied to your mod's Assets directory
    #YOURMOD=$(CIVINSTALL)\Mods\MyMod
    


    Step 6: Add the source files.
    The source files are the files which contain the C++ code. These are the files with the .cpp, .h and .inl extensions.

    I've prepared an archive of the BTS 3.19 source files, which you can extract (it also contains the CvGameCoreDLL folder). The source files should be in the same folder as the Makefile, .vcproj and .sln files.

    Alternatively, you can take these files from your BTS install folder (in the CvGameCoreDLL folder): You should copy all the .cpp, .h, .inl, .rc files into CvGameCoreDLL (you'll only have 1 .rc file).
    CvTextScreens.cpp is not used, so you can skip copying it.
    Another change you need to make after you copy the files from the BTS folder is in the file CvGameTextMgr.cpp: comment out (add // to the beginning of the line) line 2085 (inside the function createTestFontString, the first line in the function which starts with szString.append), otherwise you might have problems compiling.

    A 3rd option is that you don't want to base your code on BTS 3.19, but on another mod. Simply take the C++ source code files of this mod and copy them into the CvGameCoreDLL folder.
    Note that some mods only publish the source files which they have changed, so you should probably first copy the BTS files to the CvGameCoreDLL folder, and override it with the mod's files.

    Important: If you base your mod on another mod which has its own C++ source files - use the 3rd option.

    And that's it. Everything should (hopefully) work now.

    How to compile

    Open Visual C++ 2008 which you've installed in step 1. In it, open (File->Open->Project/Solution) the CvGameCoreDLL.sln file inside the CvGameCoreDLL folder.
    On the top of the window (below the menu) you will see a drop-down box with either 'Debug' or 'Release' in it. These are the two configurations in which you can compile.

    Release is the configuration which you will use when you release your mod (hence the name). You can of course use it before that. This is the more optimized configuration: It'll run faster, and the final DLL file will be much smaller (same as the DLL which is released with the game).

    Debug is the configuration which allows you to perform debugging on your code. When debugging, you have several advantages:
    - If the game crashes, you'll see the line in the code in which it crashed (and all the functions that called it).
    - You can place 'breakpoints' in certain points in the code, so when this code is about to run, the game will pause and you will gain control over the run of the game. You can then watch all the variables' values, run the program line-by-line and even make on-the-fly changes to the values.

    However, the debug DLL is both slower and much larger than the Release one, so only use it while developing your mod.

    After you've selected a configuration, Simply go to the 'Build' menu and choose 'Build Solution' (or press F7). This will start the compilation process. If there are modified source files, this will save them first.

    If everything's OK, it will produce a CvGameCoreDLL.dll file in either the Debug or Release subfolder, and if you added it in the makefile - it will also be copied directly to your mod's folder.

    You should make sure to place CvGameCoreDLL.dll in your <BTS installation>/Mods/<Mod Name>/Assets folder, so the game will load it.
    If it's not there, there won't be any error, since the game will simply load the default DLL, and things might not work later on in the game.

    That's it. Let me know if it works, or if this guide needs corrections or improvements.
     
    Damagemax likes this.
  2. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Working with Visual Studio

    Some of the information in this part might be a little obvious, but I figured it couldn't hurt to add it. Some of it, however, is probably completely new to people who have never worked with Visual Studio before.

    A minor tip first - if you want to show line numbers in the VS editor, go to 'Tools --> Options --> Text Editor --> All Languages' and check the 'Line Numbers' check box (must Microsoft complicate everything?).

    In the VS environment you have a few useful tools. Most of them have their own window (toolbox), which can be docked anywhere you see fit. You can cram a few windows into one toolbox window in separate tabs (drag them until you find how).

    There are two different modes for VS - Editing/Compiling and Running/Debugging. When you debug (see below), the set of opened windows and their position is different, since you usually need different tools. More on this in the 'How to Debug' section.

    Most windows can be found in the 'View' menu - some under 'Other Windows'.
    Debug-specific windows can be found under the 'Debug' menu (under 'Windows'). Some of these windows will only appear there while in Running/Debugging mode.

    Not in any particular order, these are the tools I recommend keeping opened for the Editing/Compiling (most also apply for the debugging mode):

    The solution explorer
    This is the file tree you can see, usually to your left, when you open a project in VS. Using this you can easily access any file in the project - simply double click it (or right click and choose 'View Code') and the file will open.

    You will notice that the root (main node) of the tree is the solution, and this node contains the project node. A solution can hold more than one project, but the CvGameCoreDLL solution only holds one project.
    In the CvGameCoreDLL project, all .cpp files are in the 'Source Files' folder, and all .h files are in the 'Header Files' folder. You can create folders and subfolders and drag files between them so you can find them more easily (e.g. put all AI files in a specific folder). Doing so will not move the actual files on disk, but only their view in the project tree.

    Note that the list of files here does not influence the actual compilation, since this is done using the makefile. This also means that if you use a mod's code and this mod has files which are not in the original BTS source folder, you will not see these files in the solution explorer even if they're in the project's folder and compile properly. You can add them to the project quite easily: either right click the project and select 'Add --> Existing Item', or simply drag the file into the project tree.
    You might want to do it, for example, so when you search in the project you will be able to find what you're looking for in these files as well.
    (See 'Find Results' below).

    Find Results 1/2
    Much like any advanced text editor, VS allows you to search text in multiple files. You can do it using the 'Find In Files'/'Find And Replace' (Ctrl-Shift-F): In the 'Look in' field select 'Entire Solution' or 'Current Project'.
    In the 'Result options' at the bottom of the dialog box you can select in which window the results will appear.
    Double clicking a result in one of these windows will open the relevant file in the relevant line.

    Output
    This window is opened by default. In it you will see both the progress of the compilation process and the output of the running game (when you run it in the debugger).
    When compiling, you can see in the output window all the errors and warnings which are issued by the compiler. Double clicking any of them will jump to the relevant file and line.
    However, it is much simpler to use the Error List window for these.

    Error List - important for compiling!
    When you compile, all errors and warnings appear in the output window, but they can become clattered really fast. This window displays the errors and warnings in an easy to use table. In the window, above the table itself, you have toggle buttons to show/hide errors, warnings and other messages.
    Double clicking an error or warning will jump to the relevant file and line.
    Sometimes the output window might have additional information regarding the error/warning which does not appear in this window. In this case, after double clicking the error/warning you can go to the output window, and the correct line will already be marked there.

    Before Debugging

    As I mentioned, debugging allows you to watch the code runs step-by-step, in addition to some other useful tools.
    You cannot start debugging if your project does not compile! If you have any compilation errors - fix them first.

    These are the steps you need to start debugging:

    Step 1: Build your project (or solution, doesn't matter since there's only one project in the solution) using the 'Debug' configuration.

    Step 2: Make sure the DLL file which was created (in the Debug folder) is copied to your mod's Assets folder.

    Step 3: Configure the game to run in window mode (not full screen), otherwise you might have problems switching between the game and VS. You can do that in 'My Games\Beyond The Sword' folder, in the main INI file:
    Code:
    ; Specify whether to play in fullscreen mode 0/1/ask
    FullScreen = 0
    
    1 means fullscreen, 0 means window mode.
    (You should have a shortcut to this file from the BTS folder).

    Step 4: Configure the project to run BTS with your mod:

    In the solution explorer window, right click the project (the node named 'CvGameCoreDLL' below the solution), and select 'Properties'.
    In the tree on the left go to 'Configuration Properties -> Debugging'.



    Make sure that the active configuration is debug (at the top of this dialog).

    Set the 'command' field to the full path of the BTS executable.

    In the 'command arguments' type:
    Code:
    -mod="Mods\<Your mod name>"
    (Without the '<>', obviously). This is to tell the BTS to start with your Mod.

    In the 'working directory' field enter the full path of your BTS installation folder (where the exe file sits).

    Click 'OK' and you're good to go.
    These parameters will be saved in your project's user settings file, so you don't need to enter them every time you want to debug.

    Debugging using Visual Studio

    To start debugging, run the game from within VS. You do it with 'Debug -> Start debugging' (or F5, or the little green 'play' triangle at the top of the VS window).

    These is what you're likely to come across:



    This project is out of date: CvGameCoreDLL. Would you like to rebuild?
    This means you have made changes in the code since the last time you compiled. Generally speaking, you always want to answer yes to this question, and you can do so be checking the "Do not show this dialog again" check box.
    This will always happen when using a makefile (as in this case), since VS cannot know whether the project needs to be recompiled.

    If you really changed the code, and the DLL was recompiled, it is important that you make sure to copy the Debug DLL after you build it to the Mod folder, otherwise it will not be loaded (enabling the 'auto copy' option in the makefile is the preferred way).



    Debugging information for 'Civ4BeyondSword.exe' cannot be found or does not match. Symbols not loaded. Do you want to continue debugging?
    Again, you always want to answer 'yes' to this question. This means that the exe itself is not a debug exe, so you won't be able to debug its code. Since you don't intend to, there's no problem.
    You will still be able to debug the DLL.

    Usually at this point the game will start running. You might have problems running it directly from VS (for example - you might get the error
    'A debugger has been detected. Unload the debugger and try again.' - not sure why, but it happened).
    In this case you can do everything as stated above, but instead of running the game from VS, run it externally (don't forget to load your mod!) and then attach to its process.
    You can do so in the menu: Either 'Debug --> Attach to Process' or 'Tools --> Attach to Process'. You will there see a list of processes running on your PC. Select the BTS executable and press 'Attach'. From this point on it'll be the same as running the game from within the VS, with one difference: Stopping the process (pressing the 'stop' button with the square on it, or Shift-F5) will not kill the process but only detach VS from it.

    So what can you do here?

    Breakpoints - You can add breakpoints which will cause the game execution to stop at certain points in the code by clicking next to the source code line (to the left), or by going to this line and pressing F9. You will see a red circle next to this line. If the circle is empty - it means that this source code file was not loaded for this process for some reason, and that the breakpoint will not be hit. Make sure you copied the compiled DLL!
    You can see the list of the existing breakpoints in the 'breakpoints' window.

    After breaking, the game is paused, and the debugger has the control. You can see a few options in the Debug menu:

    F5 - continue running (until the next breakpoint or forever).
    F10 - Run to the next code line.
    F11 - Run to the next code line, but if a function is called step into it.
    Shift-F5 - kill game (or detach, if you previously attached to it).

    When the game is paused, you can watch the current values of variables by hovering over them in the source code.
    It's usually easier, however, to see them in the debug windows (these are only available when debugging - you can find them under 'Debug-->Windows'):

    Autos Window contains the variables relevant for the current (and maybe previous) line of code.
    Locals Window contains all the local variables of the current function. If you're in a class method, you will also see the 'this' pointer.
    Watch Window will show you all the variables you add to it. You can either directly type into it the name of the variable, or right click the variable in the source code and select 'Add Watch'.

    In any of these windows (and in the hovering value) you can also edit the value of a variable. What it does is actually change the value that is stored in memory , so when you continue running it'll be as if you've assigned this value in code. This can also easily cause problems in this session, so keep that in mind when changing values.

    Another important window for debugging is the Call Stack Window, which shows you the current function and the entire call chain for this function.

    See for example, this screen shot:



    You can see the Call Stack in the bottom of the VS window. Here you see That the game is currently paused in CvUnitAI::AI_update() (line 93), which was called by CvSelectionGroupAI::AI_update(), etc.
    The grayed out lines are the function calls for which you have no code, which means anything which is not in the DLL - such as the exe or windows libraries.

    You can double click a line (you better only do it for lines for which you have the code) to go to the relevant source code. Then you'd be able to watch the variables there as well.

    In addition to all of that, if the game crashes while the debugger is attached to the game, VS will pop and show you exactly where in the code the crash has happened, just as if you have put a breakpoint there. That way you can check the variables values to determine the cause of the crash.
     
  3. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    (Reserved again. Who knows? might need it)
     
  4. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    Nice guide. I've got two minor additions:

    [edited since the guide was updated]

    Also, VC2008 Express will ask you to register with Microsoft. If for some reason you don't want to, temporarily change the system's date to 2009 when launching the program.
     
  5. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Thanks embryodead. I uploaded the file to CFC and updated the guide.

    EDIT: I've removed Microsoft components from the CFC database, since it was brought to my attention that it could cause trouble to CFC. I updated the links accordingly.
     
  6. need my speed

    need my speed Rex Omnium Imperarium

    Joined:
    Oct 3, 2009
    Messages:
    2,035
    Gender:
    Male
    Location:
    European Union (Magna Batavia)
    Since you said to post anything concerning this guide here, I've copied this wall of text:

    Well, I've tried everything, but still, the compiling doesn't work. Here's what I do and have, exactly:

    I have created a MyMod folder in BTS, in it are the files:

    CvGameCoreDLL.ncb
    CvGameCoreDLL.sln
    CvGameCoreDLL.vcproj
    What seems to be a backup presumely caused by a failed compilation, CvGameCoreDLL.vcproj.*the computer's / user's name*
    a .7z file that I downloaded from your guide
    depends
    Makefile
    MakefileORG (the one where I hadn't changed the path locations, thus, the original, hence the ORG)
    sources.mk

    And any other files from your guide which I needed, including the map CvGameCoreDLL if I remember correctly. Your guide said something about opening a file inside that map, if I remember correctly, although I hadn't put that file in that map, but instead, just in the MyMod folder. I tried both ways anyway. Both, however, gave an error, it couldn't find a location, the path was wrong, something like that.

    Then, experimenting, I also put in the BTS folders, and overwrote those with the RevDCM folders (which I already had merged with that BonusCommerceModifiers mod). Yet, still, a path was wrong, it gave the same error. As was to be expected.

    1>------ Build started: Project: CvGameCoreDLL, Configuration: Release Win32 ------
    1>Performing Makefile project actions
    1>Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1>Het bestand is niet gevonden
    1>Het bestand is niet gevonden
    1> "C:\Program Files (x86)\Microsoft Visual Studio 9.0\bin\cl.exe" /nologo /MD /O2 /Oy /Oi /G7 /DNDEBUG /DFINAL_RELEASE /Fp"Release\CvGameCoreDLL.pch" /GR /Gy /W3 /EHsc /Gd /Gm- /DWIN32 /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /Yu"CvGameCoreDLL.h" /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files (x86)\Microsoft Visual Studio 9.0/include" /I"C:\Program Files (x86)\WindowsSDK/Include" /I"C:\Program Files (x86)\WindowsSDK/Include/mfc" /I"C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\CvGameCoreDLL\Boost-1.32.0/include" /I"C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\CvGameCoreDLL\Python24/include" /YcCvGameCoreDLL.h /Fo"Release\_precompile.obj" /c _precompile.cpp
    1>C:\Program wordt niet herkend als een interne
    1>of externe opdracht, programma of batchbestand.
    1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\bin\cl.exe' : return code '0x1'
    1>Stop.
    1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
    1>Build log was saved at "file://c:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\MyMod\Release\BuildLog.htm"
    1>CvGameCoreDLL - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Well, that's the error. I'm guessing I'm doing something stupid, but I can't figure out what...
     
  7. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    @need my speed - luckily, we have Google translate for the dutch errors ;)

    It seems that because of the space in "c:\program files" something went wrong.
    Can you post your makefile and I'll look into it?

    Do you have the bin folder in your MyMod folder (and the fastdep.exe file in it)?
    Are all the source files in your MyMod folder as well?
     
  8. need my speed

    need my speed Rex Omnium Imperarium

    Joined:
    Oct 3, 2009
    Messages:
    2,035
    Gender:
    Male
    Location:
    European Union (Magna Batavia)
    Oh, sorry... I automatically assumed that it was all in English. :p Yes, I have the bin folder with the fastdep.exe (the only file in there), and i assume all the source files are in my mod's folder too. You mean the .lib or whatever it were files right? Those 3 or so files? Here's the makefile:

    http://www.megafileupload.com/en/file/293131/Makefile.html

    And I'll translate those Dutch messages for convenience:

    Het bestand is niet gevonden
    The file isn't (can't be) found

    Program wordt niet herkend als een interne of externe opdracht, programma of batchbestand.
    Program isn't recognized as an intern or extern command, program or batchfile.

    That last message I translated is a bit strange though, 'program' is English and not Dutch, the Dutch word for it is 'programma'. I guess 'opdracht' should be translated into 'command' in this sentence, but it could be something else.
     
  9. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Oh, I wasn't joking. I did translate these messages using Google translate :D

    The TOOLKIT path should be the one in which you've extracted the 2003 toolkit (step 2) and not where you've installed Visual Studio 2008.
    (It had nothing to do with the space in the path. It just prints the error message that way - I've recreated the problem on my PC)

    You know that you can attach small files as attachments in the post, right? there's no need to go to megafileupload for that.

    And just to make sure - the source files are also in MyMod folder, right?
     
  10. need my speed

    need my speed Rex Omnium Imperarium

    Joined:
    Oct 3, 2009
    Messages:
    2,035
    Gender:
    Male
    Location:
    European Union (Magna Batavia)
    Oh, I knew you had translated them, but if someone else read it, they would need to translate it too, et cetera...

    I guess the source files are there, but I don't really remember what files the source files were... I'll redownload the 2003 toolkit then. So, the path should be this? C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003. I'll test wether it works...

    Well, the new error is:

    1>------ Build started: Project: CvGameCoreDLL, Configuration: Release Win32 ------
    1>Performing Makefile project actions
    1>Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1>The file couldn't be found
    1>The file couldn't be found
    1> "C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\bin\cl.exe" /nologo /MD /O2 /Oy /Oi /G7 /DNDEBUG /DFINAL_RELEASE /Fp"Release\CvGameCoreDLL.pch" /GR /Gy /W3 /EHsc /Gd /Gm- /DWIN32 /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /Yu"CvGameCoreDLL.h" /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003/include" /I"C:\Program Files (x86)\WindowsSDK/Include" /I"C:\Program Files (x86)\WindowsSDK/Include/mfc" /I"C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\CvGameCoreDLL\Boost-1.32.0/include" /I"C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\CvGameCoreDLL\Python24/include" /YcCvGameCoreDLL.h /Fo"Release\_precompile.obj" /c _precompile.cpp
    1>_precompile.cpp
    1>c1xx : fatal error C1083: Cannot open source file: '_precompile.cpp': No such file or directory
    1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\bin\cl.exe"' : return code '0x2'
    1>Stop.
    1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
    1>Build log was saved at "file://c:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\MyMod\Release\BuildLog.htm"
    1>CvGameCoreDLL - 3 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
     
  11. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Oh, I haven't thought of that...

    The source files are the files with the C++ code (all the .cpp, .h, .inl files), and also the resource file (CvGameCoreDLL.rc).

    Yes, something like that.

    EDIT: The new error means that you don't have the source files in the folder. See step 6.
     
  12. need my speed

    need my speed Rex Omnium Imperarium

    Joined:
    Oct 3, 2009
    Messages:
    2,035
    Gender:
    Male
    Location:
    European Union (Magna Batavia)
    But I have those... Well, I've now not only put the CvGameCoreDLL folder inside my mod's folder, but put all the files from there also directly in it. Well, that made it work. Now I'll see wether the game actually works... Well, the game worked. But, parts of RevDCM were missing (while I could choose the Religious victory, there weren't any added options in the list where 'New random seed upon reloading', 'Aggresive AI', and those things are). Then, when the game loaded, there was no interface. When I opened World Builder (the 'interface' that appears when pressing Escape did appear), there again was no interface. I then quit with Ctrl Alt Delete because I couldn't quit in any other way... So, what went wrong?
     
  13. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    I don't exactly understand the situation here, but it might be related to this:

    You should make sure that you place the produced DLL file in your <BTS installation>/Mods/<Mod Name>/Assets folder, otherwise the game won't load it.

    It might be that the you didn't copy your DLL there, so the game loaded the normal DLL (not RevDCM's).
    After a successful compilation, the DLL will be created in the Debug or Release subfolder of CvGameCoreDLL (depending on the configuration you used).

    I will add this explanation to the guide.

    You can change the makefile so it will automatically copy the DLL once its done with compilation (see inside the spoiler tag in step 5).

    I hope it solves the problem.

    Note that you don't have to place the folder with all the C++ source files, the project and the makefile inside your mod's folder in the BTS installation path. You can, but you can equally put it in another place entirely, as long as the DLL is copied to the mod's folder.

    BTW, what OS do you use (XP/Vista/7, 32/64 bit)? I'd like to be able to remove the comment at the start of the guide.
     
  14. need my speed

    need my speed Rex Omnium Imperarium

    Joined:
    Oct 3, 2009
    Messages:
    2,035
    Gender:
    Male
    Location:
    European Union (Magna Batavia)
    Well, I did exactly as you sayed... Could it be that the compilation somehow went wrong?

    Windows 7, 64 bit.
     
  15. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    First let's see whether the compilation was successful:
    Which configuration did you use?
    If debug - look in the CvGameCoreDLL/Debug subfolder.
    If release - look in the CvGameCoreDLL/Release subfolder.

    Do you have a file called CvGameCoreDLL.dll in this folder? (this will be one of the last modified files, so you can sort by last modified to find it easily)

    If not - then the compilation failed (and then we'll start looking at the errors).

    If it's there - then the compilation succeeded.
    If the compilation succeeded - then you need to copy this file into the Assets folder of your mod.
    Is it already there?
     
  16. need my speed

    need my speed Rex Omnium Imperarium

    Joined:
    Oct 3, 2009
    Messages:
    2,035
    Gender:
    Male
    Location:
    European Union (Magna Batavia)
    Yes, I pressed F7, the .dll appeared in the release folder which was in my mod's folder, I copied the .dll and put it into the Asset folder of my mod, just like other mods (for example, RevDCM) have, and just like you said. So yes, all those things are how they should be.
     
  17. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Then the problem is not in this end.
    Maybe you have problems with your Python or XMLs?
    Try enabling python exceptions and look at the logs.

    Another possibility is that you have a bug in your C++ code ;)
     
  18. need my speed

    need my speed Rex Omnium Imperarium

    Joined:
    Oct 3, 2009
    Messages:
    2,035
    Gender:
    Male
    Location:
    European Union (Magna Batavia)
    How do I enable such exceptions and where should I look at them?
     
  19. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    In your BTS folder you should have shortcuts to the Civ4Config, where you should see:

    Code:
    ; Enable the logging system
    LoggingEnabled = 0
    
    Change it to 1.

    Then, in the BTS folder you also have a shortcut to Civ4Logs folder, where you have PythonErr.log.

    But before that - make sure you have all the Assets from RevDCM (or whichever modmod you're using) in your mod's folder.
     
  20. need my speed

    need my speed Rex Omnium Imperarium

    Joined:
    Oct 3, 2009
    Messages:
    2,035
    Gender:
    Male
    Location:
    European Union (Magna Batavia)
    Well, since I am merging a mod with RevDCM, I merged the .xml's manually, and now only need to merge the CvGameCoreDLL.dll's. So while I do not have the original RevDCM files in my mod's folder, I do have the files. Besides that, I already modded RevDCM quite heavily, just only by XML.

    I just see, I have copied all the files (as far as I can see) of RevDCM... Maybe that is the problem? I have also made a screenshot to show what I meant with 'missing interface'. Also notice the strange icon that is in front of the message that my Scout has popped a goody hut.

    http://img211.imageshack.us/img211/7121/ditisnederlandsleuktoch.png

    Ah yes... The interface...

    Traceback (most recent call last):
    File "<string>", line 1, in ?
    File "<string>", line 52, in load_module
    File "CvEventInterface", line 17, in ?
    File "<string>", line 52, in load_module
    File "BugEventManager", line 102, in ?
    File "<string>", line 52, in load_module
    File "CvEventManager", line 12, in ?
    File "<string>", line 52, in load_module
    File "CvScreensInterface", line 3, in ?
    File "<string>", line 52, in load_module
    File "CvMainInterface", line 6, in ?
    File "<string>", line 52, in load_module
    File "CvScreenEnums", line 67, in ?
    AttributeError
    :
    type object 'CvPythonExtensions.CivilopediaPageTypes' has no attribute 'CIVILOPEDIA_PAGE_CONCEPT_DCM'

    Failed to load python module CvEventInterface.
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    Traceback (most recent call last):

    File "CvAppInterface", line 70, in preGameStart

    AttributeError: 'module' object has no attribute 'showTechChooser'
    ERR: Python function preGameStart failed, module CvAppInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    Traceback (most recent call last):

    File "CvAppInterface", line 47, in onSave

    AttributeError: 'module' object has no attribute 'onEvent'
    ERR: Python function onSave failed, module CvAppInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface
    ERR: Call function onEvent failed. Can't find module CvEventInterface

    Yes... As I said, the interface...

    But it still gives that error, even when I'm using the exact same files of RevDCM, but only with my CvGameCoreDLL.dll.
     

Share This Page