Installing and using the SDK

dlordmagic said:
If you downloaded all the components which include VC++ toolkit 2003,platform SDK, the 3 libraries msvcprt, msvcrt, and msvcrtd and codeblocks. After you have installed the VC++ toolkit 2003 place the three library files into the C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib folder. After that its about setting up codeblocks. All of these components can be found in the 1st post before the picture diagrams. If this doesnt work you most likely didnt get the library files.

These 3 libraries are there.
Just to make myself clear: i can compile the project and it works fine in release mode. But the goal is to make the debug mode work. mjs0 said he succeeded by making the above mentioned steps.

I also had some success:
I simply made a copy of msvcprt.lib and renamed it to msvcprtd.lib.
Then I could compile the project and start the game, but it didn't stop at my breakpoints. First, I figured out, that the debugger included with Code::Blocks doesn't work with the MSVC++ 2003 compiler.
Then I downloaded "Debugging Tools for Windows" from Microsoft.
This program told me, that there is no debug information in my project.
So, I activated the compiler flag /Zi (Produce debugging symbols).
Well, now I have the compiler error C1067: compiler limit: debug information module size exceeded.

Matze
 
MatzeHH said:
Of cause not. This file is not freely distributed by Microsoft.
But mjs0 was talking about the linker option "Multi-Threaded DLL Runtime Library [/MD]", which should not use the msvcprtd.lib but the msvcprt.lib, which is delivered with the toolkit.
Switching on that linker option did not solve the problem, because the linker still searches the msvcprtd.lib.
He solved that problem by manually excluding the msvcprtd.lib, but didn't tell us, how.

Matze

Unfortunately, since I am not using the CodeBlock editor I don't know where in that UI you would set this linker option.
In VisualStudio.NET 2003 it is in the project properties dialog in the "Configuration Properties/Linker/Input" section as 'Ignore specific library'
If it helps, this manifests on the linker command line as /NODEFAULTLIB:"msvcprtd.lib"
You then have to explicitly pull in msvcprt.lib to replace the debug version you just excluded.

I still had to start CivilizationIV.exe as a separate process then attach to that process from VS2003. Once I did that I could debug perfectly, set breakpoints, change variable values, etc...
 
mjs0 said:
If it helps, this manifests on the linker command line as /NODEFAULTLIB:"msvcprtd.lib"
You then have to explicitly pull in msvcprt.lib to replace the debug version you just excluded.

Yea, that helps! Thanks.

Do you use the compiler option /Zi?

Matze
 
MatzeHH said:
Do you use the compiler option /Zi?
Below are all my command line options for the compiler and the linker as generated by VS2003. As you can see I have /ZI rather than /Zi but this means basically the same it just includes the VS2003 support for edit and continue as well as the regular debug data.

Compiler:
/Od /G7 /I "Boost-1.32.0\include" /I "Python24\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "CVGAMECOREDLL_EXPORTS" /D "_WINDLL" /D "_MBCS" /FD /EHsc /MD /Gy /GR /Yu"CvGameCoreDLL.h" /Fp"Debug/CvGameCoreDLL.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /ZI /Gd /TP

Linker:
/VERBOSE /OUT:"../Assets/CvGameCoreDLL.dll" /INCREMENTAL /NOLOGO /LIBPATH:"Python24\libs" /LIBPATH:"boost-1.32.0\libs\\" /DLL /NODEFAULTLIB:"msvcprtd.lib" /DEBUG /PDB:"Debug/CvGameCoreDLL.pdb" /SUBSYSTEM:WINDOWS /IMPLIB:"Debug/CvGameCoreDLL.lib" /MACHINE:X86 boost_python-vc71-mt-1_32.lib winmm.lib msvcprt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ".\Boost-1.32.0\libs\boost_python-vc71-mt-1_32.lib"
 
Thanks for your help!

Unfortunately I still have this compiler error:
CyCityInterface1.cpp
e:\Microsoft Visual C++ Toolkit 2003\include\memory(498) : fatal error C1067: compiler limit : debug information module size exceeded

Searching the net, I figured out, that this has something to do with to many characters in a class name or a constant.

Any idea?

Matze
 
Well, I kicked that Code::Blocks from my Harddisk, went to my office and grabbed a copy of Visual Studio 2003.
I followed your instructions and finally I got the debug mode running.

This is really great! Understanding the code is so much easier with the debug mode! It would have last days to find out why the AI doesn't build my brand new settleboats without the debug mode.

Matze
 
MatzeHH said:
finally I got the debug mode running
That's Great, congratulations!
MatzeHH said:
Understanding the code is so much easier with the debug mode!
I agree completely...debug mode is fantastic for understanding what the AI is thinking (so to speak) and stepping through combat and many other interesting routines.
 
Well, I have run into MAJOR difficulties. I hope someone can sort me out :).

When I get to the Build ------> Build step, I get the following error message:

LINK Fatal Error LNK1104: cannot open file 'msvcprt.lib'


So, what does it mean, and how do I get around it?

Aussie_Lurker.
 
Aussie_Lurker,
I assume you are using the free toolkit from MS...(BIG assumption)

A few minutes of googling came up with this...

For some reason MS in their infinite wisdom does not ship msvcprt.lib with the freely downloadable toolkit.

You can build it yourself using the instructions in section 3.2 of this page...
http://www.delta3d.org/article.php?story=20050721180227305&topic=tutorials

or

you can download it directly from the link towards the bottom of this page...
http://root.cern.ch/root/Procedure/Procedure to install the free Microsoft Visual C.htm

Of course, if you prefer I can just send da boys round to sort you out :)
 
Is anyone else here completely lost? :confused:

Can someone help me a little more with the basics, i dont understand a thing..

Or maybe i have the wrong Visual studio.. i downloaded the newest version called VC++ 2005 Express Edition, does that work just as good?
 
VC++ Express Edition won't work. You'll need VC++ 2003 Toolkit or Visual Studio 2003 .NET to compile a usable DLL. Sorry, there is currently no other way.

If you can't get the Visual Studio, refer to the first post of this thread and follow the instructions.
 
ive done that, but i still end up on the page where it says that the vc++ toolkit is an old version and that i cant download it.. and then i get to the same place where they tell me to download the new 2005 express..

dammit :mad: .. oh well

thx anyway
 
mjs0 said:
Eureka! :beer: :dance: :clap: I finally got debug mode to work.

It turns out that even though I was using /MD (standard multi-threaded runtime for DLLs) rather than /MDd (debug multi-threaded runtime for DLLs) it was still pulling in one of the debug libraries (msvcprtd.lib).
I have no idea why this was pulled in to the linked DLL so I took the brute force approach of specifically excluding that library and adding the standard equivalent (msvcprt.lib) to the additional dependencies list.
I can now successfully start Civ4 in its own process using the debug version of the DLL. If I then attach a VS debug session to that process I can happily set breakpoints and step through the code!

As a quick test I manually changed the experience of a unit using the C++ debugger and when I hit continue my spearman suddenly had quite a few promotions coming! (Now where did I see that tank!)

Hope this helps others who might be having the same problem.
Martin.

I compiled CvGameCoreDLL.dll (and copy to Assets\).
Because I never used debuger: HOW to debug Civ4? :confused:
I have tried Tools->Debug Processes... and then attach Civ4 process, but I can't change any variable, and when set breakpoint game freezes (this is probably normal), but then I can't gain acces to the Microsoft Visual Studio .NET 2003.
 
MatzeHH said:
Thanks for your help!

Unfortunately I still have this compiler error:
CyCityInterface1.cpp
e:\Microsoft Visual C++ Toolkit 2003\include\memory(498) : fatal error C1067: compiler limit : debug information module size exceeded

Searching the net, I figured out, that this has something to do with to many characters in a class name or a constant.

Any idea?

Matze

I made some progress on this. It is caused by putting too many boost.python .def()'s in one file.
See http://www.boost.org/libs/python/doc/v2/faq.html#c1204.

For example, in CyCityInterface1.cpp:
Code:
void CyCityPythonInterface1(python::class_<CyCity>& x)
{
	OutputDebugString("Python Extension Module - CyCityPythonInterface1\n");

	x
		.def("isNone", &CyCity::isNone, "void () - is the instance valid?")
		.def("kill", &CyCity::kill, "void () - kill the city")
		.def("doTask", &CyCity::doTask, "void (int eTaskTypes, int iData1, int iData2, bool bOption) - Enacts the TaskType passed")
		.def("chooseProduction", &CyCity::chooseProduction, "void (int /*UnitTypes*/ eTrainUnit, int /*BuildingTypes*/ eConstructBuilding, int /*ProjectTypes*/ eCreateProject, bool bFinish, bool bFront) - Chooses production for a city")
		// repeat for 380 lines...

The fix is simple, just break it up into a smaller files. Then modify CvDLLPython.cpp to call the smaller files. I attached the files I patched to make CyCityInterface1.cpp compile with debug symbols. (You need to add the new files 2,3,4,5,6 with CodeBlocks Project -> Add Files...)

Files that need to be broken up:
CyCityInterface.cpp (done)
CyGameInferface.cpp
CyGlobalContextInterface1.cpp
CyGlobalContextInterface4.cpp
CyMapInterface.cpp
CyPlayerInterface1.cpp
CyPlotInterface1.cpp
CyTeamInterface.cpp
CyUnitInterface1.cpp

After commenting out all the .def()'s in the above files I compiled with debug symbols successfully.
 

Attachments

  • fatal_error_C1067_FIX.zip
    15.7 KB · Views: 255
OK, really DUMB question here but, what does Compiling actually entail-and how do I go about it?
For example, I have added two new XML 'hooks' for civics-namely StateReligionCommerceModifier and StateReligionYieldModifier. Obviously I have also gone through the rest of the CvInfos source and header to add the various arrays where they belong etc etc, but now I want to make it in to my final product. This is obviously where compiling comes into it, but I can't find a 'Compiler' button in Code::Blocks. Could someone point me in the right direction?
Thanks in advance.

Aussie_Lurker.
 
Am I correct that no one has yet managed to succesfully run Debugging through CodeBlocks? McV aproach seems to be the closest anyone has gotten though it will probably be a quite a hastle to make the alterations all signs are that once completed he will be able to compile and debug with CodeBlocks alone. If so I sugjest we all pitch in and work through thouse Interface files ASAP.
 
Top Bottom