Compiling MFC from command line using NMAKE

One interesting point using Visual C++ 2010 samples is contained in the MFC folder. You can build mfc samples using a makefile using this command: nmake -a -f makefile. The makefile file just contains your obj files, and then the RC part. Then you #include mfcsamps.mak and that’s all.

Sample:

PROJ=MODELER1
OBJS=AppInit.obj CalendarBar.obj ChildFrm.obj ClassView.obj \
Data.obj \
DrawingContext.obj DrawingElements.obj \
Element.obj ElementContainer.obj ElementFactory.obj ElementManager.obj  \
FileView.obj MainFrm.obj Modeler1.obj Modeler1Doc.obj  \
Modeler1SourceView.obj Modeler1View.obj OutputWnd.obj PropertiesWnd.obj RibbonListButton.obj SourceCodeView.obj TabbedView.obj \
ScintillaCtrl.obj ScintillaDocView.obj

USES_OLE=1

!include <mfcsamps.mak>

# Update the resource if necessary
Modeler1.res: Modeler1.rc resource.h
    rc $(rcflags) $(rcvars) -r -fo Modeler1.res Modeler1.rc

The project is named Modeler1 and the first part of the makefile contains the obj files. You take your cpp files and you write them using the obj extension. Next, the RC part is dedicated for resources.

The MFCSAMPS.MAK file is include into Microsoft Visual Studio\VC\ATLMFC\INCLUDE folder.

Advertisements

Tagged:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: