Improved CvGameCoreDLL Makefile! AND ~71% faster compilation

I must just say thanks to you DannyDaemonic. You made my life a lot easier. :goodjob:
 
Thank you for your efforts. It does compile much faster.

I have 2 issues, though:
1. When I make a change to a header file, it doesn't recompile all the needed file. I am using the makefile+fastdep 0.9 version. I copied the fastdep.exe to the bin folder and I have no error message in the output.
2. The output debug DLL is much bigger than the previous one I had... (12.3 MB vs. 15.2 MB)
 
The debug dll is slightly different due to his changes. (it's also slower). You can change it back by changing this in the makefile "/ZI" to "/Zi".
 
Thank you for your efforts. It does compile much faster.

I have 2 issues, though:
1. When I make a change to a header file, it doesn't recompile all the needed file. I am using the makefile+fastdep 0.9 version. I copied the fastdep.exe to the bin folder and I have no error message in the output.

It should be working, but there could still be bugs in fastdep or the makefile. Could you attach or send me the build log (usually called 'CvGameCoreDLL.log') in a PM? Maybe you can also send me the file 'depends'. If it's not there, also let me know that. If you're going to zip them up you could include 'Makefile' just so I could make sure no unintentional changes were made or no unintentional side effects from editing are causing a problem.

Asaf said:
2. The output debug DLL is much bigger than the previous one I had... (12.3 MB vs. 15.2 MB)

This has already been answered, but I'll give an official response. This makefile uses the setting from the included official vcproj file. The common makefile used before just includes "debugging information" with Debug builds. The new includes "Edit and Continue debugging information".

The second does sound more useful, but now that I think about it, you can't "edit and continue" using the free 2003 toolkit! In version 1.0 I'll change it back to just "debugging information".

The debug dll is slightly different due to his changes.
Right again Afforess. With Asaf's second question, mind if I ask you, does fastdep work for you in 0.9? It's working for me but I'm worried now that there's also variance in the different nmake executables I'd have to worry about.

I must just say thanks to you DannyDaemonic. You made my life a lot easier. :goodjob:
You're welcome. :)
 
Right again Afforess. With Asaf's second question, mind if I ask you, does fastdep work for you in 0.9?

Hmm, For the record, I should be able to add a new function in say, CvArea.h and .cpp, select "Build" (and not "Clean Build") and have it recompile any files that include CvArea.h? If that's how it works, it still doesn't work for me either.
 
Hmm, For the record, I should be able to add a new function in say, CvArea.h and .cpp, select "Build" (and not "Clean Build") and have it recompile any files that include CvArea.h?

Not only that, but any file that includes a header file that includes CvArea.h, and so on. For example (not real):

Code:
// CvPlot.h

#include "CvArea.h"


// CvCity.cpp

#include "CvPlot.h"

If CvPlot.h includes CvArea.h, then changing CvArea.h should cause any file that includes CvPlot.h to be recompiled, such as CvCity.cpp in the fake example above.
 
There are two separate features mentioned in the OP: using precompiled headers, and using "real" dependencies to reduce the number of files compiled. The second one is what is giving you trouble here. When I started compiling the sdk a few months ago, I also looked at the second one. I did not count exactly, but almost every .cpp file includes almost every .h file. It is over 90% "dense". This means that when it is operating correctly, "real" dependencies will save almost nothing. So I did not pursue any further about using "real" dependencies.

However, I bet that most of the speedup is coming from precompiled headers, not from "real" dependencies. I did not investigate into this one. If there is an obvious compile option to use precompiled headers, and it is possible to use that by itself, you may get most of the speedup without running into dependency problems.
 
Thank you everyone for your comments.

So regarding the debug DLL size - changed to /Zi, still bigger, but no as much. I guess I can look at the rest of the compile and link flags later. Doesn't really matter.

Regarding the dependencies - I found the problem. You compiled fastdep with VS2010, and I was missing a DLL.
Installing the relevant VC++ redistributable solved the problem, though it feels like it doesn't work as fast now, but still faster than the original. I could be wrong, though.

You should probably add an error message when fastdep fails to run.

Thanks again.
 
There are two separate features mentioned in the OP: using precompiled headers, and using "real" dependencies to reduce the number of files compiled. The second one is what is giving you trouble here.
The 71% speed up I measure is only from the precompiled headers.

Using fastdep can literally save you >99% of percent of the rebuild time, but there's simply no fair way to put a speed up on that functionality. First of all, how often do you edit a header file? Secondly, the speed up saved by avoiding the rebuild-all varies based on how many source files include the edited header.

So regarding the debug DLL size - changed to /Zi, still bigger, but no as much. I guess I can look at the rest of the compile and link flags later. Doesn't really matter.
If debug size is a real issue for everyone I could see what flags the currently popular makefile uses. With version 1.0 I've already committed to changing over to /Zi for debug mode. (There are only advantages to this.) Again, in my defense, I just loaded up the original project files included with Civ4 and copied the setting right out of there into my new makefile.

Asaf said:
Regarding the dependencies - I found the problem. You compiled fastdep with VS2010, and I was missing a DLL.
Installing the relevant VC++ redistributable solved the problem, though it feels like it doesn't work as fast now, but still faster than the original. I could be wrong, though.

You should probably add an error message when fastdep fails to run.

Thanks again.
Thanks for spotting that! I was getting frustrated chasing that down. Normally such an error will cause Windows to pop up a message box or something along those lines. I forgot to statically link the binary. I'll have to do that, or compile it with VC6, or the 2003 toolkit.

I timed the fastdep and it was less than a 10th of a second in debug mode. I can't imagine it actually adds any noticeable overhead. It's done once at the start of the build. I'll test it again before my 1.0 release.

thanks DannyDaemonic, really enjoying this :)
Glad to hear it. :)
 
Again, in my defense, I just loaded up the original project files included with Civ4 and copied the setting right out of there into my new makefile.

No need to apologize. You're doing us all a favor :)

Thanks for spotting that! I was getting frustrated chasing that down. Normally such an error will cause Windows to pop up a message box or something along those lines.

It does produce a message box when you run fastdep separately (this is how I found that). When you run it from the makefile the message box does not appear. Not sure how they do it exactly.

I timed the fastdep and it was less than a 10th of a second in debug mode. I can't imagine it actually adds any noticeable overhead. It's done once at the start of the build. I'll test it again before my 1.0 release.

It was just my feeling, and I don't know if it's justified. It still feels much faster than the original. No need to do extra work for this on my account.
 
My first post here! :)

Your makefile is real faster and well done. Gz!

Yes it works fine with Civ 4 Colonization!

But be warned. There seems to be a bug in the latest colonization SDK sources they provide.

Line 6621 of CvGame.cpp:
Code:
	OutputDebugStr(CvString::format("[CvGame::updateOceanDistances] Plots: %i, Visits: %i\n", GC.getMapINLINE().numPlotsINLINE(), iVisits).GetCString());
Should be
Code:
	OutputDebugString(CvString::format("[CvGame::updateOceanDistances] Plots: %i, Visits: %i\n", GC.getMapINLINE().numPlotsINLINE(), iVisits).GetCString());

Also, earlier, I found a bug in my Makefile that could cause problems in some versions of Windows. Re-download the latest version of the Makefile just to make sure it works for you.

That's true.

I've noticed another bug in civ4col sdk (included in steam):

Line 36 in CyPlayerInterface3.cpp :
Code:
.def("educationThreshold", &CyPlayer::educationThreshold, "int ()")
with the "educationThreshold' : is not a member of 'CyPlayer'" error message. I've removed this line, compilation is ok then. But I don't know if the game will run. And I would like to find where "educationThreshold" is defined.... removing a line is never a good thing.
 
Okay, I finally found time and energy to try your awesome makefile. And I must admit that it IS indeed quite fast. ;) But I had some hard time getting it to work. But now I can't find a solution for this error:
Code:
1>FAssert.cpp
1> "C:\Program Files\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" /DLOG_AI /D_MOD_FRACTRADE /D_MOD_SENTRY /D_MOD_GOVWORKERS /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files\Microsoft Visual C++ Toolkit 2003/include" /I"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include" /I"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include/mfc" /I"CxImage/general" /I"CxImage/jpeg" /FoRelease\FDialogTemplate.obj /c FDialogTemplate.cpp
1>FDialogTemplate.cpp
1> "C:/Program Files/Microsoft SDKs/Windows/v6.0A\bin\rc.exe" /FoRelease\CvGameCoreDLL.res /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files\Microsoft Visual C++ Toolkit 2003/include" /I"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include" /I"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include/mfc" /I"CxImage/general" /I"CxImage/jpeg" CvGameCoreDLL.rc
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>CvGameCoreDLL.rc(10) : fatal error RC1015: cannot open include file 'afxres.h'.
1>NMAKE : fatal error U1077: '"C:/Program Files/Microsoft SDKs/Windows/v6.0A\bin\rc.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://d:\CvGameCoreDLL\CvGameCoreDLL\Release\BuildLog.htm"
1>CvGameCoreDLL - 3 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Any idea what's wrong? I noticed the only place I had 'afxres.h' is in the C:/Program Files/Microsoft Platform SDK.
 
I had the same error. change where in says afxres.h to "windows.h" and it will compile. ;)
 
I had the same error. change where in says afxres.h to "windows.h" and it will compile. ;)

Thanks that seems to work, for that problem. Now it seems that I couldn't add the CxImage folder correctly:
Spoiler :
Code:
1>FAssert.cpp
1> "C:\Program Files\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" /DLOG_AI /D_MOD_FRACTRADE /D_MOD_SENTRY /D_MOD_GOVWORKERS /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files\Microsoft Visual C++ Toolkit 2003/include" /I"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include" /I"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include/mfc" /I"CxImage/general" /I"CxImage/jpeg" /FoRelease\FDialogTemplate.obj /c FDialogTemplate.cpp
1>FDialogTemplate.cpp
1> "C:/Program Files/Microsoft SDKs/Windows/v6.0A\bin\rc.exe" /FoRelease\CvGameCoreDLL.res /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files\Microsoft Visual C++ Toolkit 2003/include" /I"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include" /I"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Include/mfc" /I"CxImage/general" /I"CxImage/jpeg" CvGameCoreDLL.rc
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1> "C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\link.exe" /out:Release\CvGameCoreDLL.dll /INCREMENTAL:NO /OPT:REF /OPT:ICF /PDB:"Release\CvGameCoreDLL.pdb" /DLL /NOLOGO /SUBSYSTEM:WINDOWS /LARGEADDRESSAWARE /TLBID:1 /LIBPATH:Python24/libs /LIBPATH:boost-1.32.0/libs/ boost_python-vc71-mt-1_32.lib /LIBPATH:"C:\Program Files\Microsoft Visual C++ Toolkit 2003/lib" /LIBPATH:"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Lib" winmm.lib user32.lib Release\BetterBTSAI.obj  Release\CvArea.obj  Release\CvArtFileMgr.obj  Release\CvBugOptions.obj  Release\CvCity.obj  Release\CvCityAI.obj  Release\CvDeal.obj  Release\CvDiploParameters.obj  Release\CvDLLButtonPopup.obj  Release\CvDLLEntity.obj  Release\CvDLLPython.obj  Release\CvDllPythonEvents.obj  Release\CvDllTranslator.obj  Release\CvDLLWidgetData.obj  Release\CvEventReporter.obj  Release\CvFractal.obj  Release\CvGame.obj  Release\CvGameAI.obj  Release\CvGameCoreDLL.obj  Release\CvGameCoreUtils.obj  Release\CvGameInterface.obj  Release\CvGameTextMgr.obj  Release\CvGlobals.obj  Release\CvHallOfFameInfo.obj  Release\CvInfos.obj  Release\CvInfoWater.obj  Release\CvInitCore.obj  Release\CvMap.obj  Release\CvMapGenerator.obj  Release\CvMessageControl.obj  Release\CvMessageData.obj  Release\CvPlayer.obj  Release\CvPlayerAI.obj  Release\CvPlot.obj  Release\CvPlotGroup.obj  Release\CvPopupInfo.obj  Release\CvPopupReturn.obj  Release\CvRandom.obj  Release\CvReplayInfo.obj  Release\CvReplayMessage.obj  Release\CvSelectionGroup.obj  Release\CvSelectionGroupAI.obj  Release\CvStatistics.obj  Release\CvStructs.obj  Release\CvTalkingHeadMessage.obj  Release\CvTeam.obj  Release\CvTeamAI.obj  Release\CvTextScreens.obj  Release\CvUnit.obj  Release\CvUnitAI.obj  Release\CvXMLLoadUtility.obj  Release\CvXMLLoadUtilityGet.obj  Release\CvXMLLoadUtilityInit.obj  Release\CvXMLLoadUtilitySet.obj  Release\CyArea.obj  Release\CyAreaInterface.obj  Release\CyArgsList.obj  Release\CyArtFileMgr.obj  Release\CyArtFileMgrInterface.obj  Release\CyCity.obj  Release\CyCityInterface1.obj  Release\CyDeal.obj  Release\CyEnumsInterface.obj  Release\CyGame.obj  Release\CyGameCoreUtils.obj  Release\CyGameCoreUtilsInterface.obj  Release\CyGameInterface.obj  Release\CyGameTextMgr.obj  Release\CyGameTextMgrInterface.obj  Release\CyGlobalContext.obj  Release\CyGlobalContextInterface1.obj  Release\CyGlobalContextInterface2.obj  Release\CyGlobalContextInterface3.obj  Release\CyGlobalContextInterface4.obj  Release\CyHallOfFameInfo.obj  Release\CyHallOfFameInterface.obj  Release\CyInfoInterface1.obj  Release\CyInfoInterface2.obj  Release\CyInfoInterface3.obj  Release\CyMap.obj  Release\CyMapGenerator.obj  Release\CyMapGeneratorInterface.obj  Release\CyMapInterface.obj  Release\CyMessageControl.obj  Release\CyMessageControlInterface.obj  Release\CyPlayer.obj  Release\CyPlayerInterface1.obj  Release\CyPlayerInterface2.obj  Release\CyPlot.obj  Release\CyPlotInterface1.obj  Release\CyRandomInterface.obj  Release\CyReplayInfo.obj  Release\CySelectionGroup.obj  Release\CySelectionGroupInterface.obj  Release\CyStructsInterface1.obj  Release\CyTeam.obj  Release\CyTeamInterface.obj  Release\CyUnit.obj  Release\CyUnitInterface1.obj  Release\FAssert.obj  Release\FDialogTemplate.obj  Release\_precompile.obj Release\CvGameCoreDLL.res
1>   Creating library Release\CvGameCoreDLL.lib and object Release\CvGameCoreDLL.exp
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CxMemFile::GetC(void)" (?GetC@CxMemFile@@UAEJXZ)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CxMemFile::PutC(unsigned char)" (?PutC@CxMemFile@@UAE_NE@Z)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CxMemFile::Error(void)" (?Error@CxMemFile@@UAEJXZ)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CxMemFile::Eof(void)" (?Eof@CxMemFile@@UAE_NXZ)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CxMemFile::Flush(void)" (?Flush@CxMemFile@@UAE_NXZ)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CxMemFile::Size(void)" (?Size@CxMemFile@@UAEJXZ)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CxMemFile::Tell(void)" (?Tell@CxMemFile@@UAEJXZ)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CxMemFile::Seek(long,int)" (?Seek@CxMemFile@@UAE_NJH@Z)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall CxMemFile::Write(void const *,unsigned int,unsigned int)" (?Write@CxMemFile@@UAEIPBXII@Z)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall CxMemFile::Read(void *,unsigned int,unsigned int)" (?Read@CxMemFile@@UAEIPAXII@Z)
1>CvGame.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall CxMemFile::Close(void)" (?Close@CxMemFile@@UAE_NXZ)
1>CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall CxMemFile::CxMemFile(unsigned char *,unsigned long)" (??0CxMemFile@@QAE@PAEK@Z) referenced in function "public: void __thiscall CxMemFile::`default constructor closure'(void)" (??_FCxMemFile@@QAEXXZ)
1>CvGame.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CxMemFile::~CxMemFile(void)" (??1CxMemFile@@UAE@XZ) referenced in function "public: virtual void * __thiscall CxMemFile::`scalar deleting destructor'(unsigned int)" (??_GCxMemFile@@UAEPAXI@Z)
1>CvGame.obj : error LNK2019: unresolved external symbol "public: bool __thiscall CxImage::Destroy(void)" (?Destroy@CxImage@@QAE_NXZ) referenced in function "public: virtual __thiscall CxImage::~CxImage(void)" (??1CxImage@@UAE@XZ)
1>CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall CxImage::CxImage(unsigned long)" (??0CxImage@@QAE@K@Z) referenced in function "public: void __thiscall CxImage::`default constructor closure'(void)" (??_FCxImage@@QAEXXZ)
1>CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall CxImage::CxImage(class CxImage const &,bool,bool,bool)" (??0CxImage@@QAE@ABV0@_N11@Z) referenced in function "public: void __thiscall CxImage::`copy constructor closure'(class CxImage const &)" (??_OCxImage@@QAEXABV0@@Z)
1>CvGame.obj : error LNK2019: unresolved external symbol __imp__DeleteObject@4 referenced in function "public: bool __thiscall CvGame::takeJPEGScreenShot(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)const " (?takeJPEGScreenShot@CvGame@@QBE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CvGame.obj : error LNK2019: unresolved external symbol "public: bool __thiscall CxImage::Save(char const *,unsigned long)" (?Save@CxImage@@QAE_NPBDK@Z) referenced in function "public: bool __thiscall CvGame::takeJPEGScreenShot(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)const " (?takeJPEGScreenShot@CvGame@@QBE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CvGame.obj : error LNK2019: unresolved external symbol "public: bool __thiscall CxImage::CreateFromHBITMAP(struct HBITMAP__ *,struct HPALETTE__ *)" (?CreateFromHBITMAP@CxImage@@QAE_NPAUHBITMAP__@@PAUHPALETTE__@@@Z) referenced in function "public: bool __thiscall CvGame::takeJPEGScreenShot(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)const " (?takeJPEGScreenShot@CvGame@@QBE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CvGame.obj : error LNK2019: unresolved external symbol __imp__BitBlt@36 referenced in function "public: bool __thiscall CvGame::takeJPEGScreenShot(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)const " (?takeJPEGScreenShot@CvGame@@QBE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CvGame.obj : error LNK2019: unresolved external symbol __imp__SelectObject@8 referenced in function "public: bool __thiscall CvGame::takeJPEGScreenShot(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)const " (?takeJPEGScreenShot@CvGame@@QBE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CvGame.obj : error LNK2019: unresolved external symbol __imp__CreateCompatibleBitmap@12 referenced in function "public: bool __thiscall CvGame::takeJPEGScreenShot(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)const " (?takeJPEGScreenShot@CvGame@@QBE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>CvGame.obj : error LNK2019: unresolved external symbol __imp__CreateCompatibleDC@4 referenced in function "public: bool __thiscall CvGame::takeJPEGScreenShot(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)const " (?takeJPEGScreenShot@CvGame@@QBE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>Release\CvGameCoreDLL.dll : fatal error LNK1120: 23 unresolved externals
1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\link.exe"' : return code '0x460'
1>Stop.
1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
1>Build log was saved at "file://d:\CvGameCoreDLL\CvGameCoreDLL\Release\BuildLog.htm"
1>CvGameCoreDLL - 26 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
It was one of the things that caused me some headache. I don't even remember what's the need of those files. :sad:
 
A quick and dirty fix for that would be to dump all of the files from that folder into your CvGameCoreDLL folder. DannyDaemonic will probably have a cleaner solution later.
 
Top Bottom