CvGameCoreDLL Build Error boost/python/list.hpp

LPlate2

Warlord
Joined
Dec 27, 2018
Messages
299
Hi,

I'm trying to do my first dll build.
I'm using Leoreth's and Nightingale 's tutorials for guidance.

I'm using the Master of Mana source code.
I'm using the files in the BtS boost and python folders.

The most repetitive error I get is, CvGameCoreDLL.h(160): fatal error C1083: Cannot open include file: 'boost/python/list.hpp': No such file or directory
When I check the python folder in the boost folder, it includes a list.hpp file.

The other error I get is boost-1.32.0\include\boost\regex\src.cpp(33): fatal error C1083: Cannot open include file: 'boost/regex.hpp': No such file or directory.
When I look in the regex folder in the boost folder, it includes a src.cpp file.

Any suggestions as to how I fix these errors?

thanks
 
Hi,

Thanks. Progress made.

I copied the boost and python folders directly into a folder where I had the sourcecode. I didn't include any lines referencing finding the BOOST/PYTHON or GLOBALBOOST/GLOBALPYTHON in the Makefile.

Output on doing the build was,
1>------ Build started: Project: CvGameCoreDLL, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(37,5): warning MSB8005: The property 'NMakeBuildCommandLine' doesn't exist. Skipping...
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

There is the CvGameCoreDLL C+/++ Header file in the original folder. There's now also various CvGameCoreDLL files (SQL Server Compact Edition Database File, Microsoft Visual Studio Solution, VC++ Project, VC++ Project Filters File, USER File) in a CvGameCoreDLL folder.

What I can not find is an actual CvGameCoreDLL.dll file to copy into my mod.

Is there some further action I need to make in Visual C++ 2010 Express or am I just looking in the wrong place?
 
Hi,

I copied the nmake.exe file across.
I hit Build in Visual Studio again.
The build output has the same message as in my previous post.
I still can't find any new CVGAMECOREDLL. dll file.
 
Hi,

I tried doing a DLL rebuild with the Creatures in War source and got the same error message, C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(37,5): warning MSB8005: The property 'NMakeBuildCommandLine' doesn't exist. Skipping...

My Makefile for the project I'm working on is;
Spoiler :
Code:
####  Civilization 4 SDK Makefile  ####
#### Copyright 2010 Danny Daemonic ####
#######################################

#### Paths ####
##TOOLKIT=C:/Program Files (x86)/Microsoft Visual C++ Toolkit 2003
##PSDK=C:/Program Files/Microsoft SDKs/Windows/v6.0A
## Uncomment to have newly compiled dlls copied to your mod's Assets directory
##YOURMOD=D:\spiele\Sid Meier's Civilization 4\Beyond the Sword\Mods\Master of Mana Workspace
## LPLate Above is original MoM Paths.
TOOLKIT=C:/Program Files (x86)/Civ4SDK/Microsoft Visual C++ Toolkit 2003
PSDK=C:/Program Files (x86)/Civ4SDK/WindowsSDK
YOURMOD=C:\Users\USER\Documents\Modding\dll SDK\WIP\LPlateBuild
## LPlate, end edits

#### Tools ####
CC="$(TOOLKIT)/bin/cl.exe"
CPP="$(TOOLKIT)/bin/cl.exe"
LD="$(TOOLKIT)/bin/link.exe"
RC="$(PSDK)/bin/rc.exe"
## Uncomment to build dependencies using fastdep
#FD="$(MAKEDIR)/bin/fastdep.exe"

#### BLACKLIST ####
## Uncomment to block CvTextScreen (accidentally included by Firaxis)
BLACKLIST=CvTextScreens

#### You shouldn't need to modify anything beyond this point ####
#################################################################

#### Target Files ####
Debug_BIN=Debug\CvGameCoreDLL.dll
#Debug_RESOURCE=Debug\CvGameCoreDLL.res
Debug_STATICLIB=Debug\CvGameCoreDLL.lib
Debug_LIBDEF=Debug\CvGameCoreDLL.def
Debug_PCH=Debug\CvGameCoreDLL.pch
Debug_PDB=Debug\CvGameCoreDLL.pdb
Debug_OTHER=Debug\CvGameCoreDLL.exp Debug\CvGameCoreDLL.ilk
Release_BIN=Release\CvGameCoreDLL.dll
#Release_RESOURCE=Release\CvGameCoreDLL.res
Release_STATICLIB=Release\CvGameCoreDLL.lib
Release_LIBDEF=Release\CvGameCoreDLL.def
Release_PCH=Release\CvGameCoreDLL.pch
Release_PDB=Release\CvGameCoreDLL.pdb
Release_OTHER=Release\CvGameCoreDLL.exp

#### CFLAGS ####
#GLOBAL_CFLAGS=/GR /Gy /W3 /EHsc /Gd /DWIN32 /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /Yu"CvGameCoreDLL.h"
#Debug_CFLAGS=/MD /Zi /Od /D_DEBUG /RTC1 /Fp"$(Debug_PCH)" $(GLOBAL_CFLAGS)
GLOBAL_CFLAGS=/GR /Gy /W3 /EHsc /Gd /DWIN32 /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /Yu"CvGameCoreDLL.h"
Debug_CFLAGS=/MD /Zi /Od /D_DEBUG /RTC1 /Fp"$(Debug_PCH)" $(GLOBAL_CFLAGS)
Release_CFLAGS=/MD /O2 /Oy /Oi /G7 /DNDEBUG /DFINAL_RELEASE /Fp"$(Release_PCH)" $(GLOBAL_CFLAGS)

#### LDFLAGS ####
GLOBAL_LDFLAGS=/DLL /NOLOGO /SUBSYSTEM:WINDOWS /LARGEADDRESSAWARE /TLBID:1
Debug_LDFLAGS=/INCREMENTAL /DEBUG /PDB:"$(Debug_PDB)" /IMPLIB:"$(Debug_STATICLIB)" $(GLOBAL_LDFLAGS)
Release_LDFLAGS=/INCREMENTAL:NO /OPT:REF /OPT:ICF /PDB:"$(Release_PDB)" $(GLOBAL_LDFLAGS)

#### INCLUDES ####
GLOBAL_INCS=/I"$(TOOLKIT)/include" /I"$(PSDK)/Include"
PROJECT_INCS=/IBoost-1.32.0/include /IPython24/include /Itbb/include
Debug_INCS=$(PROJECT_INCS) $(GLOBAL_INCS)
Release_INCS=$(PROJECT_INCS) $(GLOBAL_INCS)

#### LIBS ####
GLOBAL_LIBS=/LIBPATH:"$(TOOLKIT)/lib" /LIBPATH:"$(PSDK)/Lib" winmm.lib user32.lib
PROJECT_LIBS=/LIBPATH:Python24/libs /LIBPATH:boost-1.32.0/libs/ boost_python-vc71-mt-1_32.lib tbb.lib
Debug_LIBS=$(PROJECT_LIBS) $(GLOBAL_LIBS) msvcprt.lib #/NODEFAULTLIB:msvcprtd.lib
Release_LIBS=$(PROJECT_LIBS) $(GLOBAL_LIBS)

#### Objects ####
Debug_LINKOBJS=$(Debug_OBJS)
Release_LINKOBJS=$(Release_OBJS)

#### Auto SOURCES/OBJS ####
!IF [echo SOURCES= \> sources.mk] == 0 && \
    [for %i in (*.cpp) do @echo. "%i" \>> sources.mk] == 0 && \
    [echo.>> sources.mk] == 0 && \
    [echo Debug_OBJS= \>> sources.mk] == 0 && \
    [for /f "delims=." %i in ('dir /b *.cpp') DO @echo. Debug\%i.obj \>> sources.mk] == 0 && \
    [echo.>> sources.mk] == 0 && \
    [echo Release_OBJS= \>> sources.mk] == 0 && \
    [for /f "delims=." %i in ('dir /b *.cpp') DO @echo. Release\%i.obj \>> sources.mk] == 0 && \
    [echo.>> sources.mk] == 0
!INCLUDE sources.mk
!IF [del sources.mk]
!ENDIF
!ENDIF

#### Targets ####
#################

.PHONY: all clean Debug_clean Release_clean Debug Release

all: Debug Release

clean: Debug_clean Release_clean

Debug_clean:
   @for %i in ($(Debug_BIN) $(Debug_STATICLIB) $(Debug_LIBDEF) \
       Debug\*.obj Debug\*.@ $(Debug_RESOURCE) \
       $(Debug_PCH) $(Debug_PDB) $(Debug_OTHER)) DO @if exist "%i" del "%i"

Release_clean:
   @for %i in ($(Release_BIN) $(Release_STATICLIB) $(Release_LIBDEF) \
       Release\*.obj Release\*.@ $(Release_RESOURCE) \
       $(Release_PCH) $(Release_PDB) $(Release_OTHER)) DO @if exist "%i" del "%i"

Debug: Debug_DIR Debug_unfinished $(Debug_PCH) $(Debug_BIN)
!IFDEF YOURMOD
   -copy "$(Debug_BIN)" "$(YOURMOD)\Assets\."
!ENDIF

Release: Release_DIR Release_unfinished $(Release_PCH) $(Release_BIN)
!IFDEF YOURMOD
   -copy "$(Release_BIN)" "$(YOURMOD)\Assets\."
!ENDIF

Debug_DIR:
   -@if not exist "Debug\." mkdir "Debug"

Release_DIR:
   -@if not exist "Release\." mkdir "Release"

Debug_unfinished:
   @echo.>Debug\unfinished.@
   @for /f "delims=@" %i in ('dir /b Debug\*.@') DO \
       @if exist "Debug\%i" del "Debug\%i"
   @for /f %i in ('dir /b Debug\*.@') DO \
       @if exist "Debug\%i" del "Debug\%i"

Release_unfinished:
   @echo.>Release\unfinished.@
   @for /f "delims=@" %i in ('dir /b Release\*.@') DO \
       @if exist "Release\%i" del "Release\%i"
   @for /f %i in ('dir /b Release\*.@') DO \
       @if exist "Release\%i" del "Release\%i"

$(Debug_BIN): $(Debug_LINKOBJS) $(Debug_RESOURCE)
   $(LD) /out:$(Debug_BIN) $(Debug_LDFLAGS) $(Debug_LIBS) $(Debug_LINKOBJS) $(Debug_RESOURCE)

$(Release_BIN): $(Release_LINKOBJS) $(Release_RESOURCE)
   $(LD) /out:$(Release_BIN) $(Release_LDFLAGS) $(Release_LIBS) $(Release_LINKOBJS) $(Release_RESOURCE)

.cpp{Debug}.obj:
   @echo.>"$*.obj.@"
    $(CPP) /nologo $(Debug_CFLAGS) $(Debug_INCS) /Fo$*.obj /c $<
   @del "$*.obj.@"

.cpp{Release}.obj:
   @echo.>"$*.obj.@"
    $(CPP) /nologo $(Release_CFLAGS) $(Release_INCS) /Fo$*.obj /c $<
   @del "$*.obj.@"

$(Debug_PCH) Debug\_precompile.obj:
   @echo.>"$(Debug_PCH).@"
   @echo.>"Debug\_precompile.obj.@"
   $(CPP) /nologo $(Debug_CFLAGS) $(Debug_INCS) /YcCvGameCoreDLL.h /Fo"Debug\_precompile.obj" /c _precompile.cpp
   @del "$(Debug_PCH).@"
   @del "Debug\_precompile.obj.@"

$(Release_PCH) Release\_precompile.obj:
   @echo.>"$(Release_PCH).@"
   @echo.>"Release\_precompile.obj.@"
    $(CPP) /nologo $(Release_CFLAGS) $(Release_INCS) /YcCvGameCoreDLL.h /Fo"Release\_precompile.obj" /c _precompile.cpp
   @del "$(Release_PCH).@"
   @del "Release\_precompile.obj.@"

.rc{Debug}.res:
   @echo.>"$*.res.@"
   $(RC) /Fo$@ $(Debug_INCS) $<
   @del "$*.res.@"

.rc{Release}.res:
   @echo.>"$*.res.@"
   $(RC) /Fo$@ $(Release_INCS) $<
   @del "$*.res.@"

!IFDEF BLACKLIST

Debug\$(BLACKLIST).obj: $(BLACKLIST).cpp
   @echo.>"$*.obj.@"
   @echo.>"$*-dummy.cpp"
   $(CPP) /nologo $(Debug_CFLAGS) $(Debug_INCS) /Y- /Fo$@ /c "$*-dummy.cpp"
   @del "$*-dummy.cpp"
   @del "$*.obj.@"

Release\$(BLACKLIST).obj: $(BLACKLIST).cpp
   echo.>"$*.obj.@"
   echo.>"$*-dummy.cpp"
   $(CPP) /nologo $(Release_CFLAGS) $(Release_INCS) /Y- /Fo$@ /c "$*-dummy.cpp"
   del "$*-dummy.cpp"
   del "$*.obj.@"
!ENDIF

!IFDEF FD
!IF [$(FD) --objectextension=obj -q -O Debug $(SOURCES) > depends] == 0 && \
    [$(FD) --objectextension=obj -q -O Release $(SOURCES) >> depends] == 0
!ENDIF
!ENDIF

!IF EXIST(depends)
!INCLUDE depends
!ENDIF

The lines I've edited are rows 10 to 14.
The MAKEDIR line (row 22), was commented out in the Makefile I based mine on. Do I need to uncomment this and point it somewhere specific? If so, what to I need to amend this to?

My folder with the source, includes the Makefile, Boost-1.32.0 folder, Python24 folder and nmake.exe file, as well as the various .h and .cpp files. It also now has the CvGameCoreDLL folder, which contains a Debug folder, obj folder, readme file and various CvGameCoreDLL files but not a CvGameCoreDLL.dll. Snapshot of the files in the folder is attached.

In Visual C++ 2010 Express, when creating a New Project, I selected, "Makefile Project". I entered the Name as "CvGameCoreDLL" and the Location as the folder containing the files/folders I identified above. I did not amend any settings for Debug Configuration Settings on the Makefile Project Wizard popup, so they are all blank, apart from Output (for debugging), which was prepopulated. For Release Configuration Settings on the Makefile Project Wizard popup, I have "Same as debug configuration" ticked (so all of the other options are greyed out).

Does anyone know where I'm going wrong or how I can fix this?

thanks
 

Attachments

  • BuildFolder.PNG
    BuildFolder.PNG
    102.4 KB · Views: 195
Hi,

I've downloaded the suggested makefile.

The errors I now get when hitting Build are;
Spoiler :

1>------ Build started: Project: Civ4DLL, Configuration: Debug Win32 ------
1> Building source list
1> Running fastdep
1> The system cannot find the path specified.
1>NMAKE : fatal error U1077: '"bin\fastdep.exe"' : return code '0x1'
1> Stop.
1> 'C:\Program' is not recognized as an internal or external command,
1> operable program or batch file.
1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\bin\cl.exe' : return code '0x1'
1> Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Debug
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake dll /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



I have the steam installation, so had amended the CIV4_PATH line in the Makefile to CIV4_PATH=$(PROGRAMFILES)\Steam\steamapps\common\Sid Meier's Civilization IV Beyond the Sword\Beyond the Sword\CvGameCoreDLL.

Does the fastdep file need to be moved or a reference to its location updated?

The error message above mentions '"C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\bin\cl.exe'. However, C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin seems to be where the cl.exe file is located on my laptop. How can I correct this? Changing the Makefile to use TOOLKIT=$(PROGRAMFILES)\Microsoft Visual Studio 10.0 did not fix it and changing it to TOOLKIT=$(PROGRAMFILES)\Microsoft Visual Studio 10.0\VC created a load more issues.

What do I need to do with respect to the MSB3073 errors?

:confused: Almost at the pulling my hair out stage. :confused:
 
NMAKE : fatal error U1077: '"bin\fastdep.exe"' : return code '0x1'
Make sure you have that file present. You should have bin next to the makefile and inside it the makefile expects fastdep.exe to be present. If you want to use the fast targets (compiling with all cores), then you need jom.exe too. Unlike fastdep, jom is however a luxury and you can compile without it if needed, but then you will only use a single CPU core.
 
Okay. Moving the fastdep into a bin folder moved things on a little. The first error from the last post is now gone. The error message is now reduced to,
Spoiler :

1>------ Build started: Project: Civ4DLL, Configuration: Debug Win32 ------
1> Building source list
1> Running fastdep
1> 'C:\Program' is not recognized as an internal or external command,
1> operable program or batch file.
1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\bin\cl.exe' : return code '0x1'
1> Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Debug
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake dll /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I tried creating a bin folder in the Microsoft Visual Studio 10.0 folder and copying the cl.exe file to there. That has not made any difference.
The only place where 'C:\Program' is in the makefile is as part of commented out text, so I assume its the fastdep or nmake which has this reference.

Looking at the makefile it does have the following lines;
#### Tools ####
CC="$(TOOLKIT)\bin\cl.exe"
CPP="$(TOOLKIT)\bin\cl.exe"
LD="$(TOOLKIT)\bin\link.exe"
RC="$(PSDK)\bin\rc.exe"
and TOOLKIT was previously defined in the makefile as;
TOOLKIT=$(PROGRAMFILES)\Microsoft Visual Studio 10.0.

cl.exe and link.exe are both in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin on my laptop.
Do I need to amend the CC,CPP and/or LD references to include VC? - Edit: Tried that and there was no change to the error message so I'm changing those lines back to Nightingale's original references.

Any further suggestions?
 
Last edited:
I haven't read the whole thread carefully, but this sounds wrong to me:
The error message above mentions '"C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\bin\cl.exe'. However, C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin seems to be where the cl.exe file is located on my laptop.
There is a cl.exe in \VC\bin, but there should also be one in the toolkit folder. I'm attaching a screenshot of C:\Program Files (x86)\Microsoft Visual C++ Toolkit 2003\bin\ on my system. If you download the updated toolkit that @alberts2 recently posted here in the C2C forum, you can put the files wherever your toolkit variable points to (no installer).
I don't think this is going to remove the "'C:\Program' is not recognized" error though.
 

Attachments

  • VS Toolkit cl.jpg
    VS Toolkit cl.jpg
    159.4 KB · Views: 211
Hi,

So I tried both of the suggested approaches.
1) After copying cl.exe and link.exe into the bin folder, the error messages I get are;
Spoiler :

1>------ Build started: Project: Civ4DLL, Configuration: Debug Win32 ------
1> Building source list
1> Running fastdep
1> AI_ChooseProduction.cpp
1>.\.\AI_ChooseProduction.cpp(686): error C2065: 'iI' : undeclared identifier
1>.\.\AI_ChooseProduction.cpp(686): error C2065: 'iI' : undeclared identifier
1>.\.\AI_ChooseProduction.cpp(686): error C2065: 'iI' : undeclared identifier
1>.\.\AI_ChooseProduction.cpp(688): error C2065: 'iI' : undeclared identifier
1>NMAKE : fatal error U1077: 'bin\cl.exe' : return code '0x2'
1> Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Debug
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake dll /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


2) Downloading @alberts2 toolkit and referencing this from the Makefile, resulted in the following error messages;
Spoiler :

1>------ Build started: Project: Civ4DLL, Configuration: Debug Win32 ------
1> Building source list
1> Running fastdep
1> 'bin\cl.exe' is not recognized as an internal or external command,
1> operable program or batch file.
1>NMAKE : fatal error U1077: '"bin\cl.exe' : return code '0x1'
1> Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Debug
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake dll /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



I don't know which approach is bringing me closer to actually managing to compile something. I imagine 1) is slightly further along the track as it seems to have started dealing with the cpp files. In both cases, I'm hitting NMAKE : fatal error U1077: 'bin\cl.exe' issues.

What is the difference between return code '0x2' and return code '0x1'?

I've had a look through the AI_ChooseProduction.cpp file, searching for iI. It's used several times. I'm assuming that the (686) and (688) in the error messages regarding AI_ChooseProduction relate to the line numbers on which the errors occured. Lines 686 to 688 are;
Spoiler :
Code:
    for (iI = 0; iI < GC.getNumDamageTypeInfos(); iI++)
    {
        iValue += GC.getUnitInfo(eUnit).getDamageTypeCombat((DamageTypes) iI) *((bOnlyDefense)? 1 : 2);
    }

One thing that struck me as I looked at this was that on those lines, spaces rather than tabbing appears to be used at the start of the lines in question. If its anything like python, this would cause a problem. I changed the spaces to tabs and tried a rebuild of the 1) option. That didn't change anything. I still get the same error messages;
Spoiler :

1>------ Build started: Project: Civ4DLL, Configuration: Debug Win32 ------
1> Building source list
1> Running fastdep
1> AI_ChooseProduction.cpp
1>.\.\AI_ChooseProduction.cpp(686): error C2065: 'iI' : undeclared identifier
1>.\.\AI_ChooseProduction.cpp(686): error C2065: 'iI' : undeclared identifier
1>.\.\AI_ChooseProduction.cpp(686): error C2065: 'iI' : undeclared identifier
1>.\.\AI_ChooseProduction.cpp(688): error C2065: 'iI' : undeclared identifier
1>NMAKE : fatal error U1077: 'bin\cl.exe' : return code '0x2'
1> Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Debug
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake dll /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


 
I don't know which approach is bringing me closer to actually managing to compile something. I imagine 1) is slightly further along the track as it seems to have started dealing with the cpp files.
Looks like it. :D Unsurprisingly, as Nightinggale is the person much more likely to be able to help with this. Until he returns though:

I assume that this is your source code:
https://sourceforge.net/p/masterofmana/code/HEAD/tree/Source/AI_ChooseProduction.cpp
Changing the for loop as follows –
for (int iI = 0; iI < GC.getNumDamageTypeInfos(); iI++)
– should fix this particular error. It could be a sign that you're not using the same compiler version as the last person who worked on this. Your compiler is right though – that DamageType loop should declare iI instead of using the declaration from this loop a few lines above:
for(int iI=0;iI<GC.getNumBonusInfos();iI++)
One thing that struck me as I looked at this was that on those lines, spaces rather than tabbing appears to be used at the start of the lines in question. If its anything like python, this would cause a problem.
In C++, all whitespaces are essentially the same and "ignored [by the compiler] except as they serve to separate tokens," to quote the 2003 standard, i.e. they're used just for readability. Variables requiring (type) declarations is also very much unlike Python.
 
cl.exe and link.exe are both in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin on my laptop.
Opps, I missed that one. Exe and dll needs to be compiled with the same version of the compiler or interesting stuff might happen with memory allocations. Allocated memory needs to be released using the same version of the compiler. If you mix and the dll releases memory allocated by the exe, then the game will develop really weird bugs. I highly recommend not even trying to do something like that.

This is why we all use a compiler from 2003. It's not because we love that compiler. We don't. It would be awesome to get the optimization from a modern compiler, but without dealing with tracking who allocates what, mixing compilers just isn't an option.

One thing that struck me as I looked at this was that on those lines, spaces rather than tabbing appears to be used at the start of the lines in question. If its anything like python, this would cause a problem.
There are programmers, who are bad at indenting. This isn't even that bad. I have seen much worse. The people developing python decided to use indenting for programming scopes in order to force programmers to indent correctly in order to write more readable code. Python is the odd language in that sense and other languages generally don't care. It's still bad not to indent correctly because it makes reading the code harder and hard to read code is more likely to hide bugs.

Changing the for loop as follows –
for (int iI = 0; iI < GC.getNumDamageTypeInfos(); iI++)
This one confuses me. It looks like the source code was developed without declaring int in the second loop, but it's not supposed to be able to compile if that happens. Maybe it used a compiler flag, which makes the compiler assume int if nothing is declared, but that sounds dangerous to me as it can hide bugs originating from typos. As annoying as it can be with a strict compiler, the main reason for making a compiler strict and not fix obvious mistakes is to avoid bugs. If you want bugfree code, you want a stupid compiler, which never assumes anything.

Vanilla has a tendency to declare int iI at the start of the functions, but it would be more correct to do it at the start of each loop. Declaring int in each loop means you tell the compiler you aren't interested in saving the value between the loops, which in turn in edge cases can make the compiler use the available registers more efficiently. However this kind of optimization is way too minor to bother fixing.

If you want to optimize where it makes a difference, cache output of GC.getDefineINT, like in CvCityAI::AI_buildingProductionValue
PHP:
int YieldValue=GC.getDefineINT("AI_BUILDINGVALUE_PRODUCTION");
Replace it with
PHP:
static const int YieldValue=GC.getDefineINT("AI_BUILDINGVALUE_PRODUCTION");
Making it static means it will only call the slow getDefineINT the first time and then it will reuse the value each time. Making it const protects against changing the value later. From a coding difficulty point of view, this seems to be the best way to optimize in a way, which actually makes a noticeable difference. In general getDefineINT is evil towards performance and should always be cached.

However optimization is a luxury problem and shouldn't be considered before you can compile reliably.
 
[...] It looks like the source code was developed without declaring int in the second loop, but it's not supposed to be able to compile if that happens.
Actually, using your makefile and project files (well, with some modifications), code like that also compiles on my end. Though the VS (2010) code editor underlines the variable as undeclared. I think the answer to this Stack Overflow question explains why – it's a VS 2003 peculiarity. (VS 2005 at least added an option: /Zc:forScope.)
 
I think the answer to this Stack Overflow question explains why – it's a VS 2003 peculiarity.
Summary: VS 2003 doesn't comply to the C++ standard. It was fixed in 2005. Somehow I'm not surprised. It's not the greatest compiler I have ever encountered. I have had some weird issues with it, like one time it crashed when I tried to release the no longer used memory in a vector. It certainly shouldn't do that.
However overall the compiler is ok and it's the compiler we have to use. It's far from the worst compiler I have encountered.
 
Hello again,


From what you're saying, I'll need to use VS 2003, rather than VS 2010 Express. Where can I get this at this stage? When I go into Microsoft looking to download Visual Studio, its directing me to Visual Studio 2019 and I can not find VS 2003 anywhere in there for download.

On a side note, after including int in a number of cpp files and fixing a function call missing argument list problem, my current error message is;
Spoiler :

1>------ Build started: Project: Civ4DLL, Configuration: Debug Win32 ------
1> Building source list
1> Running fastdep
1> CvTextScreens.cpp
1>.\.\CvTextScreens.cpp(5): fatal error C1083: Cannot open include file: 'CvTextMgr.h': No such file or directory
1>NMAKE : fatal error U1077: 'bin\cl.exe' : return code '0x2'
1> Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "set TARGET=Debug
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake source_list /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake fastdep /NOLOGO
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: nmake dll /NOLOGO" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I can't seem to see a CvTextMgr.h file anywhere on my laptop, even though it seems to be called for in CvDefines or CvTextScreens in a few of the mods I've downloaded (The Road to War, Dune Wars, Creatures in War, FFH, as well as MoM). I'll look further into that mystery once I get VS2003 up and running and try to compile with that.
 
From what you're saying, I'll need to use VS 2003, rather than VS 2010 Express. Where can I get this at this stage?
The top sticky in this forum. https://forums.civfanatics.com/threads/the-easiest-way-to-compile-a-new-dll.608137/

I can't seem to see a CvTextMgr.h file anywhere on my laptop, even though it seems to be called for in CvDefines or CvTextScreens in a few of the mods I've downloaded
Remove CvTextScreens.cpp from your mod. It's compiled into the exe, added to the dll source by mistake by Firaxis and nobody ever managed to compile it because of the missing header file issue.
 
From what you're saying, I'll need to use VS 2003, rather than VS 2010 Express. Where can I get this at this stage?
Assuming that you've already installed the VS 2003 Toolkit and Windows SDK from Leoreth's thread, you should have all the software you need. The 2003 compiler is in the toolkit – if not in the one from Leoreth's thread (though I think it should be in there too), then in the one I linked to. As a development environment, VS 2010 is fine. You could use a more recent version instead, but that would only prolong this odyssey.

TOOLKIT=C:/Program Files (x86)/Civ4SDK/Microsoft Visual C++ Toolkit 2003
should have been the right path. Too bad that isn't working. The next best thing would be to replace the cl.exe and link.exe that you had copied from the Visual Studio 10.0 folder with the cl.exe and link.exe from the 2003 toolkit.
 
Top Bottom