Makefiles for VB applications
In some cases it is a good idea to do unnattended builds for Visual BASIC applications, such as if
you have a build manager that doesn't know how to run VB! I couldn't find out how to make makefiles for VB on the MSDN
so I found out how to do this myself. This document provides a template makefile.
This applies to Visual BASIC Version 6.
nmake.exe is the Microsoft implementation of a 'make' utility. UNIX programmers will be familiar with 'make'
but 'nmake' has a few differences in syntax, particularly in rule definition.
Top level makefiles should be run from the command line or within a batch file. Microsoft Visual BASIC 6 provides a
batch file called vcvars32.bat which sets up the necessary environment variables to run nmake and other
utilities. For Windows 95/98 and ME users it is best to add the path to where vb.exe is stored in autoexec.bat
because vcvars32.bat doesn't do this.
The path to vcvars32 is:
c:\program files\microsoft visual studio\vc98\bin\vcvars32.bat
To get VB6.EXE into your path please add:
path=%path%;"C:\Program Files\Microsoft Visual Studio\VB98"
On Windows 95/98 and ME it is best to create a shortcut to command.com on the desktop, press the right mouse button
and set the command line to "c:\windows\command.com /E:4096". This sets the environment space to 4k which is enough
to run vcvars32.bat. Windows NT and 2000 users do not need to do this because these operating systems have a decent amount of environment
space to start with.
This makefile compiles Project1.vbp to Project1.exe, other targets can be listed in the Objs.
If you have any Project1.vbp, run this boiler plate makefile from the download section.
This makefile can be run by simply running 'nmake.exe'.
# test makefile
# run with 'nmake.exe'
.SUFFIXES : .vbp
Objs = Project1.exe
VBC = vb6.exe
VBFLAGS = /make
all : $(Objs)
$(VBC) $(VBFLAGS) $<
1. The right hand side of .SUFFIXES adds a file extension to the nmake default rule list. These can be listed by running nmake with the /p option,
2. /make is the command line switch for vb6.exe to automatically compile the input .vbp file,
3. .vbp.exe is a rule stating that .exe files can be built from .vbp files. There are other default rules for building .exe files too,
4. $< outputs the right hand side of the rule (these are all listed in the MSDN documentation for nmake.exe),
5. Dependencies can be specified by normal associations and a top level rule (I haven't done much on this),
6. I haven't even thought about conditional builds of project groups within VB source code but this may be useful.
Back to index.