A simple guide to compiling the DLL

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

  1. AbsintheRed

    AbsintheRed Deity

    Joined:
    Jul 27, 2009
    Messages:
    8,288
    Location:
    Szeged, Hungary
    You were right, there were still some missing files
    But the problem wasn't in my changes, they were originally missing from the debug version of the makefile
    What I don't get is how I managed to compile a debug .dll yesterday night with it :confused:
    It must have been a corrupt one, but nothing indicated it during compiling...

    Yeah, it would have been much easier
    Thanks, hopefully I'm over with my compiling rants (for now) ;)
     
  2. modifieda4

    modifieda4 Chief Time Waster

    Joined:
    Sep 3, 2006
    Messages:
    385
    Location:
    Gold Coast
    asaf:

    awesome guide! :goodjob:

    i followed your steps and had compiled the defaul dll as a test within 10minutes.
    *the debug dll had some errors, but is seems everyone gets these (line 1295 assert)
    *the release dll ran fine, no issues.

    on to merging mods!

    thanks!
     
  3. Chazcon

    Chazcon Prince

    Joined:
    Feb 16, 2006
    Messages:
    475
    Location:
    Left Coast
    Hmm Civ 4 locks up (hangs) when I hit a breakpoint in Visual C++ 2008 Express Edition, set up as you have described Asaf, don't recall this type of hanging in the past. If it hangs on a breakpoint it's attempting to access libraries, correct? Maybe I missed a setting somewhere.

    EDIT: Doh, I was running Civ 4 in Fullscreen Mode, changing to Windowed (as you pointed out) has breakpoints working flawlessly.
     
  4. Ulysses

    Ulysses Chieftain

    Joined:
    May 21, 2003
    Messages:
    33
    Location:
    Germany
    Thanks Asaf, it seems I have compiled successfully my first dll :). (Five stars). Is it normal that the size differs from original dll? Approx. 6kb less :confused:.
     
  5. WilliamOfOrange

    WilliamOfOrange King

    Joined:
    Jul 17, 2003
    Messages:
    998
    Location:
    Lincolnshire, UK
    Thanks for this guide, Asaf. I know I will get the hang of this, but right no, I have some problems:

    I don't get the Project option on VS2010..but I think I did for '08. Don't get the build menu family either.

    Also, when I have lucked out and managed to get it to work, I cannot find a .dll file produced anywhere. What am I doing wrong?

    EDIT: got it to work.....need to refresh your folders if they are open when you do this! :lol:
     
  6. WilliamOfOrange

    WilliamOfOrange King

    Joined:
    Jul 17, 2003
    Messages:
    998
    Location:
    Lincolnshire, UK
    Success!! I added your fourth Yield into Orbis and even used your beautiful little gamefont editor. The whole process took about 20 minutes! Brilliant!
     
  7. Ferocca

    Ferocca Warlord

    Joined:
    Nov 21, 2011
    Messages:
    166
    Yeah, have the same, and therefore I am not sure if it went well or not - but the guide definitely helped, Asaf:)
     
  8. Folket

    Folket Deity

    Joined:
    Jan 7, 2010
    Messages:
    4,023
    Location:
    Sweden
    Anyone got this working for visual studio 2012?
     
  9. Folket

    Folket Deity

    Joined:
    Jan 7, 2010
    Messages:
    4,023
    Location:
    Sweden
    I got it working when using 8.0A if the windows SDK instead of 7.0A.
     
  10. vetiarvind

    vetiarvind Prince

    Joined:
    Oct 20, 2013
    Messages:
    328
    Location:
    Chennai, South India
    Having problems using VS 2012/VC++ Express 2010 and .NET framework 4 on Win 7 64. It compiles the .cpp files but I'm getting the following error while linking. I tried using the provided SDK, 7.0A, 8.0A but they're all throwing the same error for each .obj file.
    Spoiler :

    1>CyInfoInterface1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::~basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(void)" (__imp_??1?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@XZ)
     
  11. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    VS2012 or VC2010?
    In any case, I don't really know but maybe the comments here can help you.
     
  12. raystuttgart

    raystuttgart Civ4Col Modder Supporter

    Joined:
    Jan 24, 2011
    Messages:
    7,517
    Gender:
    Male
    Location:
    Stuttgart, Germany
    @vetiarvind:

    You do use "Microsoft Visual C++ Toolkit 2003" ?
    It is an absolute must, that you have that in order to compile a working DLL for Civ4Col.

    There are two additions you need.
    One is the Toolkit and the other one is the SDK (I still use good old PSDK).
     
  13. vetiarvind

    vetiarvind Prince

    Joined:
    Oct 20, 2013
    Messages:
    328
    Location:
    Chennai, South India
    I tried using both, but they have the same issue. Since I'm using a makefile there won't be a "platform toolset" option.
    Yeah the VC++ Toolkit 2003 is in order. I have the compilation working, it's just the issue with linking so maybe it's not: (1)getting the order of the libraries right(unlikely as it works for others) or (2)there's some version compatibility issue with psdk(would be strange since i tried 3 versions, all of which have atleast worked for 1 person in this forum) or (3) Some sort of 64 bit compatibility issue(others have managed to compile with win 7 64) or (4) VS is overriding the makefile's targeted toolkit or sdk with another version. (i haven't changed any defaults so don't know why i'm getting it)

    Thanks for the support guys, I'll give it another shot this Sunday. I noticed that the external references of the project points to the VS's runtime headers and not the toolkit. Might have a lead there.
     
  14. Zlatko

    Zlatko CIW

    Joined:
    Apr 1, 2010
    Messages:
    713
    Location:
    Solar System
    This thread is tutorial for DLL compiling, i am compile dll and i have next problems, can someone help me how to fix this.

    PROBLEM


    MY THREAD


    AND A+ for this tutorial ASAF!!!

    I am merge your custom (ASAF) .dll last version and TLO TAGS (SDK PROMOTIONS).
     
  15. vetiarvind

    vetiarvind Prince

    Joined:
    Oct 20, 2013
    Messages:
    328
    Location:
    Chennai, South India
    It seems the issue was that I had not copied the following three files to my VC++ Toolkit 2003 library: msvcrt.lib, msvcrtd.lib, msvcprt.lib.
    I can get it to build now.
    7.0A now works in VS 2012 Win 7 x64 for me. The issue was with VC++ Toolkit 2003 all along (atleast for me)
     
  16. marshaul

    marshaul Chieftain

    Joined:
    May 18, 2014
    Messages:
    8
    Well, I've had a very frustrating time of this. I've tried with about every permutation of Visual Studio 2008, 2012, 2013, the "WindowsSDK" provided in the first post here, the various version of Microsoft SDK (7.0A, 7.1A, 8.0, 8.0A, 8.1A), and at no point have I had success, though I've had different errors at different times.

    Some of the errors I've had have been meaningful, and I've been able to resolve. But, when I get everything else resolved, it boils down to the (seemingly) same failure, one which results in probably the most useless error I've ever encountered.

    Essentially, I get 934 warnings about various unknown pragmas. Immediately following that, I am told:

    Warning 935 warning U4010: 'Release\CvGameCoreDLL.res' : build failed; /K specified, continuing ...
    Warning 937 warning U4011: 'Release' : not all dependents available; target not built
    Warning 936 warning U4011: 'Release\CvGameCoreDLL.dll' : not all dependents available; target not built

    And finally, the only so-called "error":

    Error 938 error MSB3073: The command "nmake /NOLOGO Release_clean
    nmake /NOLOGO /K Release
    " exited with code 1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets 43 5 CvGameCoreDLL

    I didn't get all these pragma warning in Visual Studio 2008, but I also couldn't make VS2008 locate "afxres.h" (its constant source of failure).

    Anybody have any clue what's going on?
     
  17. Lemon Merchant

    Lemon Merchant Hall Monitor Super Moderator

    Joined:
    Jun 27, 2008
    Messages:
    8,726
    Gender:
    Female
    Location:
    Red Sector A
    Do you have the VC++ Toolkit 2003 installed?
     
  18. Archid

    Archid Warlord

    Joined:
    Oct 30, 2009
    Messages:
    287
    Location:
    North Wales, UK
    I am using VS2012 on Win 7 x64 and had to play around with the Include & Library directories in the project properties to get it to work. It was a painful process for me as well. In the project properties dialog->Configuration Properties->VC++ Directories:

    Code:
    [B]Include Directories[/B] C:\Program Files %28x86%29\Microsoft Visual Studio 9.0\VC\include;D:\Games\Civ4\Beyond the Sword\CvGameCoreDLL\Boost-1.32.0\include;D:\Games\Civ4\Beyond the Sword\CvGameCoreDLL\Python24\include
    [B]Library Directories[/B] D:\Games\Civ4\Beyond the Sword\CvGameCoreDLL\Python24\libs;D:\Games\Civ4\Beyond the Sword\CvGameCoreDLL\Boost-1.32.0\libs;[COLOR="Blue"]$(LibraryPath)[/COLOR]
    Make sure you are referencing the VC includes from the Program Files (x86) directory and add the LibraryPath variable at the end. You may need to change some paths to suit your system, but that is how it works for me.

    As LM says you have to be using the 2003 toolkit and I am v7.1A SDK. The entries in my makefile are:
    Code:
    TOOLKIT=D:\Apps\MicrosoftVisualC++Toolkit2003
    PSDK=D:\Apps\Microsoft SDKs\Windows\v7.1A
    
     
  19. marshaul

    marshaul Chieftain

    Joined:
    May 18, 2014
    Messages:
    8
    First of all: yes, the C++ Toolkit is installed. I tried Archid's suggestion, to no avail.

    However, in the process I think I may have stumbled across the problem, although I have no idea why it seems to be unique to my case, nor how to fix it (I'm a unix guy and freely admit to being unfamiliar with character escaping and whatnot in Windows).

    The output was being obfuscated by VS's silly habit of immediately plastering errors (no matter how useless they may be) over top of it, and my unfamiliarity with the interface.

    After chugging away for several minutes, seemingly compiling a couple dozen interface modules without issue, it suddenly decides:


    "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\rc.exe" /FoRelease\CvGameCoreDLL.res /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003/include" /I"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A/Include" /I"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A/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" CvGameCoreDLL.rc
    'C:\Program' is not recognized as an internal or external command,
    operable program or batch file.​

    It seems fairly obvious that the space characters in my path are not being properly escaped. It's the same with or without the path additions suggested by Archid (which makes sense as those seemed to be carefully escaped by the IDE), so it would seem clear the Makefile is doing this.

    However, I can't see why. Each of the include paths listed appears to be quoted, which I assume should cause spaces to be automatically escaped.

    Can I fix this without renaming (reinstalling?) everything into paths without special characters?
     
  20. marshaul

    marshaul Chieftain

    Joined:
    May 18, 2014
    Messages:
    8
    I got it!

    I moved the SDK stuff to a location with no spaces in the path.

    Also, as the "Microsoft SDKs" were split across the Program Files and Program Files (x86) directories, I had to copy the RC.exe from Program Files\Microsoft SDKs\Windows\v7.0\bin to the Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin directory. It was the v7.0A directory which I then ultimately moved & referenced in the Makefile.
     

Share This Page