Improved CvGameCoreDLL Makefile! AND ~71% faster compilation

No; Jdog or whomever removed all the CvXImage stuff from RevDCM a while ago.
 
Hello,

I'm trying to use this makefile with no success. I'm following the instructions on the Modiki and am running into the following error:


1>------ Build started: Project: CvGameCoreDLL, Configuration: Debug Win32 ------
1>
1> Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>NMAKE : fatal error U1073: don't know how to make 'release'
1> Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "nmake release" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I'm sure I'm missing something blatantly easy, but I can't come up with it. Any suggestions? I'm using VS2010.

Cheers,
ripple01
 
You didn't change the make commands.

Essentially, everywhere in that guide where it says "Final_Release", change it to "Release".

Where it says clean_Debug and clean_Final_Release, change it to Debug_clean and Release_clean.

I think that's it.

Thanks for the quick reply. I did as you said and am still getting an error message:

1>------ Rebuild All started: Project: CvGameCoreDLL, Configuration: Release Win32 ------
1>
1> Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>NMAKE : fatal error U1073: don't know how to make 'release_clean'
1> Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(33,5): error MSB3073: The command "nmake release_clean" exited with code 2.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


I've attached a screen of my nmake config if it helps at all.

Cheers,
ripple01
 

Attachments

  • NMakeScreenShot.png
    NMakeScreenShot.png
    237.6 KB · Views: 191
Only difference from mine is that it is Release, not release. Same goes for Debug.

I tried that, and it didn't seem to make a difference. Thanks for the suggestion, though. Maybe someone else will have another idea I can try.

Cheers,
ripple01
 
When I tried to create a debug build I got an error around the module size of CyCityInterface1.cpp. I saw that Afforess had the same problem and had moved a chunk of the defines into a second file: CyCityInterface2.cpp.

The compilation went through fine, but I am getting errors where the Python code cannot access the defines that I moved to CyCityInterface2.cpp. Is there anything else that I need to do other than just copy the file, change the class name and split the .def() lines? I have tried a clean and a full build.

I used the CyGlobalContextInterfaceX.cpp files as an example and used the following.

PHP:
void CyCityPythonInterface1(python::class_<CyCity>& x)
{
	OutputDebugString("Python Extension Module - CyCityPythonInterface1\n");

	x
		.def("isNone", &CyCity::isNone, "void () - is the instance valid?")
		// rest of .def() definitions here
		.def("getEspionageDefenseModifier", &CyCity::getEspionageDefenseModifier, "int ()")

		;
}


void CyCityPythonInterface2(python::class_<CyCity>& x)
{
	OutputDebugString("Python Extension Module - CyCityPythonInterface2\n");

	x
		.def("isWorkingPlotByIndex", &CyCity::isWorkingPlotByIndex, "bool (iIndex) - true if a worker is working this city's plot iIndex")
		// rest of .def() definitions here
		.def("isHasBuildingClass", &CyCity::isHasBuildingClass, "bool (int /*BuildingClassTypes*/ eBuildingClass)")

		;
}

I know that this is a bit off-thread but others may run into the same issue when creating a debug build using this new makefile. If it not related to this makefile then I will move the post over to a new thread.

Cheers,
Jim
 
Hello,

I'm trying to use this makefile with no success.

...

I'm sure I'm missing something blatantly easy, but I can't come up with it. Any suggestions? I'm using VS2010.

Cheers,
ripple01

I have a suggestion, use the VS2010 project files! I've just attached them to the original post. Let me know if they work for you. I am also thinking about building project files for other versions of Visual Studio. I might not get around to it though.

I was also thinking of packaging up the whole project, source and all, just to make it easier. Preferably with the unofficial patch. But, lets just try this to start.
 
I have a suggestion, use the VS2010 project files! I've just attached them to the original post. Let me know if they work for you. I am also thinking about building project files for other versions of Visual Studio. I might not get around to it though.

I was also thinking of packaging up the whole project, source and all, just to make it easier. Preferably with the unofficial patch. But, lets just try this to start.

Got it working, thanks for posting these!!! :goodjob::goodjob::goodjob:

Cheers,
ripple01
 
I was way too busy IRL to do more than read this thread, so I apologize for the late entry into the discussion. I'm setting BULL up to use your makefile finally and had some thoughts during the process. Let me say first a big "thank you" for doing this as it was needed. :goodjob:

Breaking up CyCityInterface.cpp

I got the error about the debugging information overflow with this file, so I checked the compiler settings. Some of the options in your makefile are redundant, and some differ in ways that I'd like to understand further.

You had these extra options:

  • General
    • /Gy - enable function-level linking
    • /Gm- - disable (?) minimal rebuild
  • Debug
    • /Zi - generate complete debugging information
    • /Od - disable optimization
  • Release
    • /Oy - omit frame pointer
    • Oi - generate intrinsic functions
For the release build, /Oy and /Oi are implied by /O2 which you have, so I removed them.

I could only find "/Gm" which enabled minimal rebuild. I assume it's off by default, but the docs didn't list the - option to this feature.

/Zi seems to be what kills CyCityInterface1.cpp. I'm trying other /Z settings but will probably end up splitting the original file as everyone else has. It might be nice to supply a pre-split file.

The main difference (not listed above) however is that I use /MDd for debug builds and link against MSVCPRTD.lib which is supposed to be for debugging. That requires "/NODEFAULTLIB:msvcprtd.lib" in the debug libs. Do you know if this is necessary? It's been a long time since I put together BULL's makefile using the original from Refar, and I had a lot of trouble probably caused by my inclusion of CxImage for MapFinder. :( I don't remember if this was something I needed to do to get it to work.

One thing I added to BULL's makefile right away is to point to the Boost and Python libraries and includes in BTS's folder rather than forcing the modder to copy them to every SDK folder. Windows shortcuts fail us here, but it's easy with this at the top:

Code:
CIV = C:\Games\Civ4\Beyond the Sword
SDK = $(CIV)\CvGameCoreDLL
BOOST = $(SDK)\Boost-1.32.0
PYTHON = $(SDK)\Python24

I modified your makefile to add a COPYTO macro instead of assuming the DLL will go into an mod's Assets folder and defined a BIN folder to hold fastdep.exe.

Code:
BIN = C:\Coding\Civ\SDK\bin
## Uncomment to have newly compiled dlls copied to your mod's Assets directory
COPYTO = $(CIV)\Assets

However, after all that I cannot get it to work with BULL. BULL includes CxImage (a mix of C and C++ files) stored in subfolders. I have the files appearing in sources.mk, but I can't figure out how to tell it to build the cpp or c files. Here's the file I ended up with:

Spoiler BULL makefile :
Code:
#### Civilization 4 SDK Makefile 1.0 ####
####  Copyright 2010 Danny Daemonic  ####
#########################################

#### Paths ####
TOOLKIT = C:\Coding\Microsoft Visual C++ Toolkit 2003
PSDK = C:\Program Files\Microsoft Platform SDK

BIN = C:\Coding\Civ\SDK\bin
CIV = C:\Games\Civ4\Beyond the Sword
SDK = $(CIV)\CvGameCoreDLL
BOOST = $(SDK)\Boost-1.32.0
PYTHON = $(SDK)\Python24

## Uncomment to have newly compiled dlls copied to your mod's Assets directory
COPYTO = $(CIV)\Assets

#### Tools ####
CC="$(TOOLKIT)\bin\cl.exe"
CPP="$(TOOLKIT)\bin\cl.exe"
LD="$(TOOLKIT)\bin\link.exe"
RC="$(PSDK)\bin\rc.exe"
#FD="$(BIN)\fastdep.exe"

#### BLACKLIST ####
BLACKLIST=CvTextScreens

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

#### Target Files ####
Debug_BIN=Debug\CvGameCoreDLL.dll
Release_BIN=Release\CvGameCoreDLL.dll

!IF [IF NOT EXIST CvGameCoreDLL.rc EXIT 1] == 0
Debug_RESOURCE=Debug\CvGameCoreDLL.res
Release_RESOURCE=Release\CvGameCoreDLL.res
!ENDIF

Debug_STATICLIB=Debug\CvGameCoreDLL.lib
Release_STATICLIB=Release\CvGameCoreDLL.lib

Debug_LIBDEF=Debug\CvGameCoreDLL.def
Release_LIBDEF=Release\CvGameCoreDLL.def

Debug_PCH=Debug\CvGameCoreDLL.pch
Release_PCH=Release\CvGameCoreDLL.pch

Debug_PDB=Debug\CvGameCoreDLL.pdb
Release_PDB=Release\CvGameCoreDLL.pdb

Debug_OTHER=Debug\CvGameCoreDLL.exp Debug\CvGameCoreDLL.ilk
Release_OTHER=Release\CvGameCoreDLL.exp

#### CFLAGS ####
GLOBAL_CFLAGS=/GR /Gy /W3 /EHsc /Gd /DWIN32 /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /Yu"CvGameCoreDLL.h"
# /Zi 
Debug_CFLAGS=/MDd /Od /D_DEBUG /RTC1 /Fp"$(Debug_PCH)" $(GLOBAL_CFLAGS)
Release_CFLAGS=/MD /O2 /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) /NODEFAULTLIB:msvcprtd.lib
Release_LDFLAGS=/INCREMENTAL:NO /OPT:REF /OPT:ICF /PDB:"$(Release_PDB)" $(GLOBAL_LDFLAGS)

#### INCLUDES ####
GLOBAL_INCS=/I"$(TOOLKIT)/include" /I"$(PSDK)/Include" /I"$(PSDK)/Include/mfc"
PROJECT_INCS=/I"$(BOOST)/include" /I"$(PYTHON)/include" /I"CxImage/general" /I"CxImage/jpeg"
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:"$(PYTHON)/libs" /LIBPATH:"$(BOOST)/libs/" boost_python-vc71-mt-1_32.lib gdi32.lib Ole32.lib
Debug_LIBS=$(PROJECT_LIBS) $(GLOBAL_LIBS) msvcprt.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 && \
    [FOR %i IN (CxImage\general\*.cpp) DO @ECHO. "%i" \>> sources.mk] == 0 && \
#    [FOR %i IN (CxImage\jpeg\*.c) 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 && \
    [FOR /F "delims=." %i IN ('dir /b CxImage\general\*.cpp') DO @ECHO. Debug\CxImage\general\%i.obj \>> sources.mk] == 0 && \
#    [FOR /F "delims=." %i IN ('dir /b CxImage\jpeg\*.c') DO @ECHO. Debug\CxImage\jpeg\%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 && \
    [FOR /F "delims=." %i IN ('dir /b CxImage\general\*.cpp') DO @ECHO. Release\CxImage\general\%i.obj \>> sources.mk] == 0 && \
#    [FOR /F "delims=." %i IN ('dir /b CxImage\jpeg\*.c') DO @ECHO. Release\CxImage\jpeg\%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 COPYTO
	-COPY "$(Debug_BIN)" "$(COPYTO)\."
!ENDIF

Release: Release_DIR Release_unfinished $(Release_PCH) $(Release_BIN)
!IFDEF COPYTO
	-COPY "$(Release_BIN)" "$(COPYTO)\."
!ENDIF

Debug_DIR:
	-@IF NOT EXIST "Debug\." MKDIR "Debug"
	-@IF NOT EXIST "Debug\CxImage\." MKDIR "Debug\CxImage"
	-@IF NOT EXIST "Debug\CxImage\general\." MKDIR "Debug\CxImage\general"
	-@IF NOT EXIST "Debug\CxImage\jpeg\." MKDIR "Debug\CxImage\jpeg"

Release_DIR:
	-@IF NOT EXIST "Release\." MKDIR "Release"
	-@IF NOT EXIST "Release\CxImage\." MKDIR "Release\CxImage"
	-@IF NOT EXIST "Release\CxImage\general\." MKDIR "Release\CxImage\general"
	-@IF NOT EXIST "Release\CxImage\jpeg\." MKDIR "Release\CxImage\jpeg"

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.@"

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

.c{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 [IF NOT EXIST $(FD) EXIT 1] == 0
!IF [$(FD) --objectextension=pch -q -O Debug CvGameCoreDLL.cpp > depends] != 0 || \
    [$(FD) --objectextension=obj -q -O Debug $(SOURCES) >> depends] != 0 || \
    [$(FD) --objectextension=pch -q -O Release CvGameCoreDLL.cpp >> depends] != 0 || \
    [$(FD) --objectextension=obj -q -O Release $(SOURCES) >> depends] != 0
!MESSAGE Error running fastdep.
!ENDIF
!ELSE
!IF [ECHO "fastdep.exe" NOT FOUND! && \
     ECHO Please edit Makefile to reflect the correct path of fastdep. && \
     ECHO. ]
!ENDIF
!ENDIF

!ENDIF

!IF EXIST(depends)
!INCLUDE depends
!ENDIF
BULL is used in a few other mods, and it seems most everyone has to remove the CxImage stuff to get it to build. Do you know how I could set up a separate CxImage project so I can build a statically-linked CxImage.lib myself to include with BULL? That way other modders could use BULL out-of-the-box?
 
Neither /ZI nor /Zi will work with larger source files because of the program database size limit. You will at least want to know the line numbers so you should add /Zd .

Can you get it to work if you just put everything into the $(SDK) folder?
 
Neither /ZI nor /Zi will work with larger source files because of the program database size limit. You will at least want to know the line numbers so you should add /Zd .

I'll try that one. Really, full debugging info would be great so you could examine variables and expressions. All of the BULL code so far was so straight-forward I didn't need to debug in VS, but this is about more than BULL. Is that the only file that is too large for /Zi?

Can you get it to work if you just put everything into the $(SDK) folder?

Probably, but I'm really hoping Danny can help me extract CxImage into a separate static library so no one has to deal with it. You removed it from Better BUG AI, right?
 
No, I didn't remove it, I just had to disable the precompiled headers to get it to work.

But I have never bothered to find out how to use a makefile when I have a vcproj I can compile from, so I never had to fiddle around with obj creation in the makefile.

/Zi vs /Zd: how much more info do you get anyway? I'm glad if I can see the line number.. Anyway I just tried it again and got no errors, both compiler and linker created their pdb files. But I have yet to manage to compile a working dll with /MTd so I'm not sure if that's even relevant.
 
/Zi should give you variable and symbol information so you can inspect them while in the debugger and create watch expressions on them: "break if pCity goes NULL".

So you're not using a makefile at all? Do you have the full VC++ 2003 IDE?
 
Top Bottom