A simple guide to compiling the DLL

Thanks Asaf,
I was able to solve my initial problem (didnt correctly follow instructions) and am now able to recompile. But im trying to make some new edits (add a civ) and i keep getting these errors; maybe you can take a look and identify whats wrong.

Spoiler :
1>CvRhyes.cpp(13) : error C2078: too many initializers
1>CvRhyes.cpp(16) : error C2078: too many initializers
1>CvRhyes.cpp(19) : error C2078: too many initializers
1>CvRhyes.cpp(20) : error C2078: too many initializers
1>CvRhyes.cpp(21) : error C2078: too many initializers
1>CvRhyes.cpp(22) : error C2078: too many initializers
1>CvRhyes.cpp(23) : error C2078: too many initializers
1>CvRhyes.cpp(24) : error C2078: too many initializers
1>CvRhyes.cpp(62) : error C2078: too many initializers
1>CvRhyes.cpp(62) : fatal error C1903: unable to recover from previous error(s); stopping compilation


And there all from this little bit of coding (starts line 13 and ends at 62)
Spoiler :
// rhyes.cpp

int startingTurn[28] = {0, 0, 0, 0, 50, 84, 66, 90, 97, 121, 145, 163, 177, 183, 187, 193, 196, 203, 205, 207, 281, 220, 234, 236, 240, 241, 249, 301, 346}; //332 for 1733

// edead: replaces the above to allow different game speeds
int startingTurnYear[28] = {-3000, -3000, -3000, -3000, -1600, -844, -1200, -753, -660, -300, 60, 330, 551, 622, 657, 718, 751, 829, 843, 860, 1500, 989, 1128, 1150, 1190, 1195, 1280, 1600, 1775};

//Alphabetical order: AME ARA AZT BAB BYZ CAR XXX CHI EGY ENG ETH FRA GER GRE HRE XXX INC IND XXX JAP KHM XXX MAL MAY MON XXX HOL TUR PER POR ROM RUS SPA XXX VIK XXX
char loadingTime[35][4] = { "60", "20", "35", "0", "15", "5", "X", "0", "0", "30", "10", "25", "30", "2", "30", "X", "35", "0", "35", "10", "20", "X", "35", "15", "35", "X", "40", "35", "5", "35", "5", "30", "25", "X", "20", "X"};
char loadingTime600AD[35][4] = { "30", "0", "15", "0", "0", "0", "X", "0", "0", "10", "0", "5", "10", "0", "10", "X", "15", "0", "15", "0", "2", "X", "15", "0", "15", "X", "20", "15", "0", "15", "0", "10", "5", "X", "0", "X"};
char startingYear[35][6] = {"1775 ", "620 ", "1200 ", "3000 ", "330 ", "1200 ", "XXX ", "3000 ", "3000 ", "820 ", "295 ", "750 ", "1600 ", "1600 ", "840 ", "XXX ", "1150 ", "3000 ", "1167 ", "655 ", "660 ", "XXX ", "980 ", "65 ", "1190 ", "XXX ", "1500 ", "1280 ", "850 ", "1130 ", "760 ", "860 ", "720 ", "XXX ", "545 ", "XXX "};
bool startingEra[35] = {true, true, true, false, true, false, false, false, false, true, false, true, true, false, true, false, true, false, true, false, true, false, true, true, true, false, true, true, false, true, false, true, true, false, true, false}; //AD or BC
char startingYear600AD[35][6] = {"1775 ", "600 ", "1200 ", "3000 ", "600 ", "1200 ", "XXX ", "600 ", "3000 ", "820 ", "295 ", "750 ", "1600 ", "1600 ", "840 ", "XXX ", "1150 ", "3000 ", "1167 ", "600 ", "660 ", "XXX ", "980 ", "65 ", "1190 ", "XXX ", "1500 ", "1280 ", "850 ", "1130 ", "760 ", "860 ", "720 ", "XXX ", "600 ", "XXX "};
bool startingEra600AD[35] = {true, true, true, false, true, false, false, true, false, true, false, true, true, false, true, false, true, false, true, true, true, false, true, false, true, false, true, true, false, true, false, true, true, false, true, false}; //AD or BC

char uniquePower[35][2][16] = {
{"TXT_KEY_UP_AME", "TXT_KEY_UP_AME2"},
{"TXT_KEY_UP_ARA", "TXT_KEY_UP_ARA2"},
{"TXT_KEY_UP_AZT", "TXT_KEY_UP_AZT2"},
{"TXT_KEY_UP_BAB", "TXT_KEY_UP_BAB2"},
{"TXT_KEY_UP_BYZ", "TXT_KEY_UP_BYZ2"},
{"TXT_KEY_UP_CAR", "TXT_KEY_UP_CAR2"},
{"XXX", "XXX"},
{"TXT_KEY_UP_CHI", "TXT_KEY_UP_CHI2"},
{"TXT_KEY_UP_EGY", "TXT_KEY_UP_EGY2"},
{"TXT_KEY_UP_ENG", "TXT_KEY_UP_ENG2"},
{"TXT_KEY_UP_ETH", "TXT_KEY_UP_ETH2"},
{"TXT_KEY_UP_FRA", "TXT_KEY_UP_FRA2"},
{"TXT_KEY_UP_GER", "TXT_KEY_UP_GER2"},
{"TXT_KEY_UP_GRE", "TXT_KEY_UP_GRE2"},
{"TXT_KEY_UP_HRE", "TXT_KEY_UP_HRE2"},
{"XXX", "XXX"},
{"TXT_KEY_UP_INC", "TXT_KEY_UP_INC2"},
{"TXT_KEY_UP_IND", "TXT_KEY_UP_IND2"},
{"TXT_KEY_UP_ITA", "TXT_KEY_UP_ITA2"},
{"TXT_KEY_UP_JAP", "TXT_KEY_UP_JAP2"},
{"TXT_KEY_UP_KHM", "TXT_KEY_UP_KHM2"},
{"XXX", "XXX"},
{"TXT_KEY_UP_MAL", "TXT_KEY_UP_MAL2"},
{"TXT_KEY_UP_MAY", "TXT_KEY_UP_MAY2"},
{"TXT_KEY_UP_MON", "TXT_KEY_UP_MON2"},
{"XXX", "XXX"},
{"TXT_KEY_UP_HOL", "TXT_KEY_UP_HOL2"},
{"TXT_KEY_UP_TUR", "TXT_KEY_UP_TUR2"},
{"TXT_KEY_UP_PER", "TXT_KEY_UP_PER2"},
{"TXT_KEY_UP_POR", "TXT_KEY_UP_POR2"},
{"TXT_KEY_UP_ROM", "TXT_KEY_UP_ROM2"},
{"TXT_KEY_UP_RUS", "TXT_KEY_UP_RUS2"},
{"TXT_KEY_UP_SPA", "TXT_KEY_UP_SPA2"},
{"XXX", "XXX"},
{"TXT_KEY_UP_VIK", "TXT_KEY_UP_VIK2"},
{"XXX", "XXX"}};
 
Oh man, I hate hard coding stuff. And this code seems particularly awful.
But since this is the way Rhye's code works, well...

It looks like you've added elements to the array without making it bigger. So, for example, in the first line (which defines startingTurn) you have 29 numbers in the list, but the array size is 28.
Change the line to be:
Code:
int startingTurn[[B]29[/B]] = {0, 0, 0, 0, 50, 84, 66, 90, 97, 121, 145, 163, 177, 183, 187, 193, 196, 203, 205, 207, 281, 220, 234, 236, 240, 241, 249, 301, 346}; //332 for 1733

And do the same for other lines you've added elements to.

When you have more than one index (for multi dimensional arrays) - for example in
Code:
char loadingTime[35][4]

Increase the first number (to 36).
 
Hi,
thanks for this very nice tutorial, the best here in my eyes.
I have just one question: May I refer to and use your uploaded files (e.g. the VC Toolkit etc.), in my german tutorial? It´s not a pure translation of this one. Permission would be very nice because it´s a good collection of the needed files.
Thanks, deepwater
 
Hi

So I've followed your instructions, and arrived here:

Spoiler :

1>------ Build started: Project: CvGameCoreDLL, Configuration: Debug Win32 ------
1>Performing Makefile project actions
1>NMAKE : fatal error U1052: file 'Debug' not found
1>Stop.
1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
1>Build log was saved at "file://f:\games\CIV IV\Beyond the Sword\Mods\Screw\CvGameCoreDLL\Debug\BuildLog.htm"
1>CvGameCoreDLL - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


At first I actually tried following the instructions here:
http://modiki.civfanatics.com/index.php/How_to_Install_the_SDK
but that gave me the same error, so that's when I moved on to your guide.

In the wiki instructions they suggest starting a command prompt from the IDE and manually entering this command if compiling from the IDE doesn't work:
nmake /f Makefile Final_Release

That didn't work with their guide, so then I tried doing the same with your guide, just changing the command to what you have in the configuration properties.
nmake /NOLOGO /K Debug

Output from that was different than compiling from the IDE:
Spoiler :

F:\games\CIV IV\Beyond the Sword\Mods\Screw\CvGameCoreDLL>nmake /NOLOGO /K Debug

File Not Found
File Not Found
"F:\programming\Microsoft Visual C++ Toolkit 2003\bin\cl.exe" /nologo /M
D /Zi /Od /D_DEBUG /RTC1 /Fp"Debug\CvGameCoreDLL.pch" /GR /Gy /W3 /EHsc /Gd /Gm-
/DWIN32 /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /Yu"CvGameCoreDLL.h" /IBoo
st-1.32.0/include /IPython24/include /I"F:\programming\Microsoft Visual C++ Tool
kit 2003/include" /I"F:\programming\WindowsSDK/Include" /I"F:\programming\Window
sSDK/Include/mfc" /I"F:\games\CIV IV\Beyond the Sword\CvGameCoreDLL\Boost-1.32.0
/include" /I"F:\games\CIV IV\Beyond the Sword\CvGameCoreDLL\Python24/include" /Y
cCvGameCoreDLL.h /Fo"Debug\_precompile.obj" /c _precompile.cpp
_precompile.cpp
c1xx : fatal error C1083: Cannot open source file: '_precompile.cpp': No such fi
le or directory
NMAKE : warning U4010: 'Debug\CvGameCoreDLL.pch' : build failed; /K specified, c
ontinuing ...
"F:\programming\Microsoft Visual C++ Toolkit 2003\bin\link.exe" /out:Deb
ug\CvGameCoreDLL.dll /INCREMENTAL /DEBUG /PDB:"Debug\CvGameCoreDLL.pdb" /IMPLIB:
"Debug\CvGameCoreDLL.lib" /DLL /NOLOGO /SUBSYSTEM:WINDOWS /LARGEADDRESSAWARE /TL
BID:1 /LIBPATH:python24/libs /LIBPATH:boost-1.32.0/libs/ boost_python-vc71-mt-1_
32.lib /LIBPATH:"F:\programming\Microsoft Visual C++ Toolkit 2003/lib" /LIBPATH:
"F:\programming\WindowsSDK/Lib" /LIBPATH:"F:\games\CIV IV\Beyond the Sword\CvGa
meCoreDLL\Boost-1.32.0/libs" /LIBPATH:"F:\games\CIV IV\Beyond the Sword\CvGameCo
reDLL\Python24/libs" winmm.lib user32.lib msvcprt.lib
LINK : warning LNK4001: no object files specified; libraries used
LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
Debug\CvGameCoreDLL.dll : fatal error LNK1120: 1 unresolved externals
NMAKE : warning U4010: 'Debug\CvGameCoreDLL.dll' : build failed; /K specified, c
ontinuing ...
NMAKE : warning U4011: 'Debug' : not all dependents available; target not built


Up to the first line beginning with "NMake" is the same output that I got using the wiki instructions, the rest is new to your setup.
The _precompile.cpp file is where it should be (with all the other source files), yet it keeps saying it can't be opened. It's not read-only, and I'm on an admin account.

Any ideas?
 
Just to make sure you have the correct setup -
In the folder "F:\games\CIV IV\Beyond the Sword\Mods\Screw\CvGameCoreDLL", you have the following files:
- A 'bin' folder with fastdep.exe in it
- CvGameCoreDLL.sln
- CvGameCoreDLL.vcproj
- Makefile (The one from this guide, in which you modified the paths)
- All source files
 
Weird. Can you zip the folder (you can skip the boost and python subfolders) and attach it?
I don't know if it's something in the folder contents, but since you already checked the admin and read-only issues...

And keep the Debug folder inside (I want to take a look at what was created there).
Does building in Release act the same?
 
Debug and Release behave the same way.
Here's what's in the folder, except for a huge .ncb file (VC++ intellisense, autocompletion in the IDE).
 
Well, there's nothing wrong with the files themselves (I was able to build with them). I also compared the makefile and project file to mine, and I even used your .suo file just in case something was wrong there.

'NMAKE : fatal error U1052: file 'Debug' not found' appears when nmake can't locate the make file.

My guess is that somehow the build command is run in a different working folder for some reason.
This could also cause the compiler to not find the .cpp files.

I added a 'cd' command so it would print the current working directory. Try building debug (I only added it to debug build, not release and not rebuild), and post your output.
 

Attachments

  • CvGameCoreDLL.7z
    2 KB · Views: 167
Case solved.

You were right, the working directory got changed.
A long long time ago I modified HKEY_CURRENT_USER\Software\Microsoft\Command Processor\Autorun value in the registry to "cd /d" to some deeply buried folder that I used a lot, then of course forgot about it.

I probably would not have figured this out on my own, my knowledge of makefile use is nill, and any errors produced are just gibberish.

Thanks a lot you kind soul :D
 
I am getting a symbols not found error when attempting to debug. I am using VS 2008, Windows 7, and am attempting to debug Legends of Revolution which is based on REvolution's .dll. I'm not getting any feedback in the Callstack box. It shows me which line it is choking on but doesn't tell me what is calling it. Any ideas?
 
A few things:
1. Did you compile the debug DLL yourself?
2. Did you make sure that you placed the DLL you compiled in the mod's assets folder?
3. Can you post a screen shot of the call stack window?
 
Thank you so much Asaf for this wonderful tutorial. Very clear, with all the useful attachments. I messed it up a bit but it was my fault, re-reading it carefully made it work fine!

Finally, after previous unsuccessfull attempts, thanks to your guide I managed to change and compile a new dll!

Excellent job!
 
A few things:
1. Did you compile the debug DLL yourself?
2. Did you make sure that you placed the DLL you compiled in the mod's assets folder?
3. Can you post a screen shot of the call stack window?

1. Yes as best as I could. There are some caveats with this particular .DLL I think, and would like to make sure I haven't missed something else.
2. Yes.
3. see attached doc.
 

Attachments

  • Doc1.doc
    221.5 KB · Views: 162
Top Bottom