Tool: Makefile to build the SDK using Visual Studio 2005 or VC++ 2005 Express

Déja

Beyond the Mod
Joined
Dec 19, 2005
Messages
353
Since VS2005's editor is so much better than VS2003, and you can get VC++ 2005 Express for free (google for it), I thought this would be nice solution for people to be able to use these superior tools to build the SDK.

****
Note
****
In theory, this should work for building using the SDK using Visual C++ 2005 Express, though I have not personally tested this.

There are also few lines in the makefile that should be changed to point to the correct path of your Visual C++ install, if it is not the default one.

**********
Instructions
**********

Simply download the makefile (attached below), rename it to "makefile.vs8", and follow the directions at the top of the makefile. I've copied and pasted the header from the makefile below:

Code:
########################################################
#
#  makefile.vs8
#
#    A Makefile for the CivilizationIV CvGameCoreDLL
#
#    Written by Déja Augustine (deja at sadgame.com)
#
########################################################
#
#  ** NOTE **
#    If you do not have VS2003 installed in its default location
#    you will have to edit the VSINSTALLDIR and VCINSTALLDIR
#    macros half-way down the file.  You may have to change other
#    options if you are using VC++ 2005 Express and the PlatformSDK.
#
#  To build the project, use the following command, either from
#    within VS2005 or on the command-line:
# 
#     > nmake /f makefile.vs8 all
#
#  To build the debug configuration, use the following instead
#
#     > nmake /f makefile.vs8 "DEBUGBUILD=_DEBUG" all
#
#   * Note that whatever you supply for DEBUGBUILD will be added
#     to the DLL's filename.  The default _DEBUG would result in
#     CvGameCoreDLL_DEBUG.dll.  This can be left blank by using
#     "DEBUGBUILD=" which would result in CvGameCoreDLL.dll
#
#  You can also substitute clean or rebuild for all 
#
#  To configure VS8/VC8 to use the makefile, simply:
#
#  1. Open the project's properties screen and change
#     Configuration Properties > General > Configuration Type to "Makefile"
#
#  2. Click Apply
#  
#  3. Most of the options will disappear and you'll be left with General, 
#     Debugging and NMake.  Under NMake, set the options to the following 
#     (for the final release):
#
#       Build Command Line: nmake /f makefile.vs8 all
#       Rebuild Command Line: nmake /f makefile.vs8 rebuild
#       Clean Command Line: nmake /f makefile.vs8 clean
#
#  4. That's it!  Now when you hit build/rebuild/clean it'll use the makefile
#
#  The debug configuration can be changed in the same manner, using the 
#    "DEBUGBUILD=" flag as listed above.
#
#  In order to add new .cpp files to the project it is necessary
#    to make changes in two places.  The first is the FILES macro,
#    and the second is the list of object files at the bottom of
#    the makefile.  There are instructions on the format in each 
#    section
#
#########################################################

Let me know if you test it with VC++ 2005 Express, so I can update the instructions to account for it better.

Also, feel free to reply here or PM me with any praise/scorn for this tool :)

Please don't forget to rename the file to makefile.vs8. The forums wouldn't let me attach it as a .vs8 file, so I had to go with makefile.vs8.txt
 

Attachments

  • makefile.vs8.txt
    31.7 KB · Views: 1,005
I re-uploaded the makefile to fix an error in the link flags. If you're one of the two people who have already downloaded it, please re-download the makefile.
 
By the way, this MAY work right out of the box for Warlords. I don't think they've added any new files or changed the dependencies, but I could be wrong. If anyone has a chance to try it, let me know if it works.
 
I haven't looked at the makefile yet, but does the debug mode work? It was hard enough to get the debug mode to work with VS2003.

Matze
 
It builds using all the debug flags that were in the VS2003 project, so if you had to set any custom flags, you'll have to change the CPPDEBUG macro in the file to include those changes, but if it built properly in debug mode before, then it will continue to do so with the makefile
 
I'm not entirely sure if I'm doing things right but I get the following errors:

When building solution -

Code:
Building Precompiled Header
 cl /O2 /G7 /D "NDEBUG" /D "FINAL_RELEASE" /MD /GR /Fp"Final/CvGameCoreDLL.pch"  /Fo"Final/" /Fd"Final/vc70.pdb" /Zi /I "Boost-1.32.0\include" /I "Python24\include"  /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "CVGAMECOREDLL_EXPORTS" /D "_WINDLL" /D "_MBCS"  /FD /EHsc /Yc"CvGameCoreDLL.h" /W3 /nologo /c /Gd /TP _precompile.cpp
cl : Command line warning D9002 : ignoring unknown option '/G7'
_precompile.cpp
c1xx : fatal error C1083: Cannot open compiler intermediate file: 'Final/CvGameCoreDLL.pch': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\bin\cl.EXE"' : return code '0x2'

When doing a rebuild or clean build -

Code:
Cleaning Output Folder
The system cannot find the file specified.
NMAKE : fatal error U1077: 'del' : return code '0x1'
 
does it prevent it from building? If there's nothing to delete, the del command will error out. There may be a way to get around that, but it seemed inconsequential.
 
I had that happen to me once or twice, but then it stopped. I never did figure out what was causing it. was a Final folder created in the same folder as the makefile?

It uses Final/ instead of Final Release/ to remove the need to have quotes all over the place to account for the space in the folder's name
 
Hm... that's bizarre. I just deleted everything that didn't come with the SDK (except the project files and makefile, of course) and it still built without issue.

I'm going to look into this further, but has anyone else experienced this problem?
 
one other question, is your CvGameCoreDLL folder write-protected (Read-Only)?

That could cause the error because cl (the compiler) can't create the output folder in a write-protected folder.

You can check this by going one folder above your CvGameCoreDLL folder, right clicking on it, selecting properties and making sure that the Read-only checkbox is empty (not filled or checked)
 
one other question, is your CvGameCoreDLL folder write-protected (Read-Only)?

Nope.

What do you do to open the project files:

1. Open the default CvGameCoreDLL VC++ project and convert it or
2. Create a new project and add the files into it?

If it works for you it's most likely I'm doing something wrong.
 
I've done it both ways. When I get home, I'll check to see if I've changed any other settings in the project files.
 
cf_nz said:
I'm not entirely sure if I'm doing things right but I get the following errors:

When building solution -

Code:
Building Precompiled Header
 cl /O2 /G7 /D "NDEBUG" /D "FINAL_RELEASE" /MD /GR /Fp"Final/CvGameCoreDLL.pch"  /Fo"Final/" /Fd"Final/vc70.pdb" /Zi /I "Boost-1.32.0\include" /I "Python24\include"  /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "CVGAMECOREDLL_EXPORTS" /D "_WINDLL" /D "_MBCS"  /FD /EHsc /Yc"CvGameCoreDLL.h" /W3 /nologo /c /Gd /TP _precompile.cpp
cl : Command line warning D9002 : ignoring unknown option '/G7'
_precompile.cpp
c1xx : fatal error C1083: Cannot open compiler intermediate file: 'Final/CvGameCoreDLL.pch': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\bin\cl.EXE"' : return code '0x2'

When doing a rebuild or clean build -

Code:
Cleaning Output Folder
The system cannot find the file specified.
NMAKE : fatal error U1077: 'del' : return code '0x1'

I get the exact same error. I am using visual studio 2005 express. I tried everything suggested above.
 
using Visual Studio 2005 Express, what did you change the makefile macros to, for them to point to the PlatformSDK?
 
I've just checked the compiler flags its showing you with the compiler flags in the CvGameCoreDLL.vcproj file that comes with the vanilla SDK, and they are identical (with the exception of Final/ instead of Final Release/

I am unable to replicate your errors.

The only thing I can think of is perhaps it's choking on the / instead of a \, but I don't know why it would work on both WinXP and Windows Vista here, and break elsewhere.

One thing to try might be to change CPPFLAGS to read Final\... instead of Final/...

If that doesn't work, then I'm pretty much out of ideas
 
Déja said:
using Visual Studio 2005 Express, what did you change the makefile macros to, for them to point to the PlatformSDK?

I put nmake /f makefile.vs8 all in the build commandline
I put nmake /f makefile.vs8 rebuild in the rebuild all commandline
I put nmake /f makefile.vs8 clean in the clean commandline

I edited the makefile to make it place the dll in the current directory by changing my dll path to DLLPATH=.. Now I get he following.
Code:
------ Clean started: Project: CvGameCoreDLL, Configuration: Debug FxsMemory Win32 ------
Performing Makefile project actions
Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.
makefile.vs8(238) : fatal error U1092: too many names in rule
Stop.
Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
CvGameCoreDLL - 2 error(s), 0 warning(s)
========== Clean: 0 succeeded, 1 failed, 0 skipped ==========

I am sorry I should have said that I am using the SDK that I found in CvGameCoreDLL of my warlords directory.
 
firstly, it may not work with warlords, as the dependencies were generated for the vanilla SDK.

Secondly, try using DLLPATH=./ to point to the same folder as the makefile
 
Also, do you want to be compiling the Final Release version? If you want to compile debug, change the command line as indicated in the header of the makefile.
 
Top Bottom