?
Solved

How do i use "nmake" to compile my DLL

Posted on 2009-04-16
7
Medium Priority
?
2,190 Views
Last Modified: 2013-11-26
I have just received a code snippet which has to be modified  for my company.  

I am trying to compile a system wide Hook code which comes with a makefile. When i run just "nmake" on the folder destination i get makefile is up-to-date. Does this mean that the code had no errors or makefile had no errors? I dont see the dll to be rebuilt anyways. I am able to compile the project using Visual studio 6 but the compiled dll size does nto match with the original dll.

I believe the right way would be to use nmake. Any help with this would be really appreciated.

I would be more than happy to email the project for compilation procedure.

Thanks
0
Comment
Question by:rupvis
  • 2
  • 2
5 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 1000 total points
ID: 24172069
There is a batch file that sets up the environment so that nMake (and other utilities such as Lib) will work from the command line even when the current directory is your project directory.  Look for a file named:
   VCVARS32.BAT
it's in your VC98\Bin directory.  Get to a command line and run that.  Then CD to your project directory and nMake (et. al) should work.
Incidently, one rarely if ever uses nmake these days.   Just use the IDE to build the project.
0
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 1000 total points
ID: 24174229
>>>> When i run just "nmake" on the folder destination i get makefile is up-to-date
Normally a makefile has a few targets. That are kind of labels at the beginning of a line and terminated by a colon :  After an empty line a new target can begin (or differently said, when reaching an empty line in the makefile the processing was stopped) So you can see a makefile as a sequence of functions begining with the target name (label) and instructions what to do behind that label. Also important is that after a target there can be an enumeration of other targets which then will be processed like functions accordingly. The last thing waht is important in a makefile is general rules, e. g. a rule which says that a .cpp file as input would produce a .obj file (.o in UNIX) as output and what is the command to so that. So if in your makefile there is a target main.obj the nmake would check whether the main.obj is older or younger than the main.cpp. If it is younger, it says the target is 'up-to-date'. Or to link your application there might be a target main.exe and a list of .obj (sub) targets which were the input for the linker. If the .exe is younger than all .obj files the nmake does nothing.

Applying that to your problem, it is most probably that you already have all .obj and .exe built, so that there is no need for the makefile to recompile or build. To test that, move all .obj files of your project folder to a different folder (or copy the folders and after that delete the .obj files in the original folder). Than run nmake and it should start to build cause the .obj files were not present. After that also the .exe were newly built cause the .exe targets were not up-to-date. Then, you should have made the environment properly for a commandline build as Dan has described above.
0
 
LVL 2

Author Comment

by:rupvis
ID: 24178777
i have run the batch file and deleted the obj files too. It would still ask me for cl.exe
Output for nmake /p

Microsoft (R) Program Maintenance Utility Version 7.10.3077
Copyright (C) Microsoft Corporation.  All rights reserved.


MACROS:

      cvarsmt = $(cvars) -D_MT -MT
PROCESSOR_IDENTIFIER = x86 Family 6 Model 15 Stepping 11, GenuineIntel
      INCLUDE = C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\incl
ude\
      psxlibs = libcpsx.lib psxdll.lib psxrtl.lib oldnames.lib
      COMSPEC = C:\WINDOWS\system32\cmd.exe
        scall = -Gz
      psxvars = -D_POSIX_
   _NMAKE_VER = 7.10.3077
     ole2libs = $(olelibs)
      PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
         MAKE = nmake
        cvars = -DWIN32 $(noansi) -D_WIN32
   olelibsdll = ole32.lib uuid.lib oleaut32.lib $(guilibsdll)
   conlibsdll = $(libcdll) $(baselibs)
   SYSTEMROOT = C:\WINDOWS
   guilibsdll = $(libcdll) $(winlibs)
         PATH = C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Progr
am Files\Java\jdk1.5.0_14\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BIN
N;C:\apache-ant-1.7.0\bin;C:\Program Files\Java\jdk1.5.0_14\bin;C:\Program Files
\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\To
ols\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Mi
crosoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft
 Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\ASG\ASGUMA\ROCHADE\bin;C:\PRO
GRA~1\ATT\Graphviz\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Mic
rosoft Visual Studio .NET 2003\SDK\v1.1\Bin;C:\WINDOWS\Microsoft.NET\Framework\v
2.0.50727;D:\Downloads\ASG Downloads\glassfish\bin;C:\instantclient-basic-win32-
10.2.0.4\instantclient_10_2;C:\Program Files\Microsoft Visual Studio\VC98\Includ
e;
NUMBER_OF_PROCESSORS = 2
         TEMP = C:\DOCUME~1\rupeshv\LOCALS~1\Temp
   cvarsmtdll = $(cvarsmt) -D_DLL
     baselibs = kernel32.lib $(optlibs) $(winsocklibs) advapi32.lib
  SESSIONNAME = Console
  _WIN32_MAK_ = 1
     conflags = $(conlflags)
  USERPROFILE = C:\Documents and Settings\rupeshv
     guiflags = $(guilflags)
COMMONPROGRAMFILES = C:\Program Files\Common Files
  LOGONSERVER = \\MASING3DC1
     HOMEPATH = \Documents and Settings\rupeshv
  ole2libsdll = $(olelibsdll)
     cvarsdll = $(cvars) -D_MT -D_DLL -MD
__COMPAT_LAYER = EnableNXShowUI
  SYSTEMDRIVE = C:
     USERNAME = rupeshv
     psxflags = $(psxlflags)
     TARGETOS = WINNT
       cdebug = -Z7 -Od
     ANT_HOME = C:\apache-ant-1.7.0
     DLLENTRY = @12
        COBOL = cobol
       cflags = $(cflags) -D_WIN32_IE=$(_WIN32_IE) -DWINVER=$(NMAKE_WINVER)
                $(cflags) -D_WINNT -D_WIN32_WINNT=$(NMAKE_WINVER)
                $(ccommon) -D_X86_=1
       ldebug = -debug:full -debugtype:cv
       lflags = /NODEFAULTLIB /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO
       libcmt = libcmt.lib oldnames.lib
ALLUSERSPROFILE = C:\Documents and Settings\All Users
       implib = lib
 VSEDEFLOGDIR = C:\Documents and Settings\All Users\Application Data\McAfee\Desk
topProtection
           BC = bc
           CC = cl
       cvtobj = REM !!! CVTOBJ is no longer necessary - please remove !!!
 PROGRAMFILES = C:\Program Files
    MAKEFLAGS = P
PROCESSOR_REVISION = 0f0b
    DEFLOGDIR = C:\Documents and Settings\All Users\Application Data\McAfee\Desk
topProtection
 COMPUTERNAME = MASINGXRUPESH
       rcvars = -DWIN32 -D_WIN32 -DWINVER=$(NMAKE_WINVER) $(noansi)
           AS = ml
           RC = rc
       cvtres = REM !!! CVTRES is no longer necessary - please remove !!!
PROCESSOR_LEVEL = 6
         libc = libc.lib oldnames.lib
    _WIN32_IE = 0x0300
PROCESSOR_ARCHITECTURE = x86
           OS = Windows_NT
    HOMEDRIVE = C:
    CLASSPATH = .;C:\Program Files\Java\jdk1.5.0_14\jre\lib\mail.jar;C:\Program
Files\Java\jdk1.5.0_14\jre\lib\dsn.jar;C:\Program Files\Java\jdk1.5.0_14\jre\lib
\imap.jar;C:\Program Files\Java\jdk1.5.0_14\jre\lib\mailapi.jar;C:\Program Files
\Java\jdk1.5.0_14\jre\lib\pop3.jar;C:\Program Files\Java\jdk1.5.0_14\jre\lib\smt
p.jar;C:\Program Files\Java\jdk1.5.0_14\jre\lib\activation.jar;C:\Program Files\
Java\jre1.6.0_06\lib\ext\QTJava.zip;E:\Fit\lib\OpenForecast-0.4.0.jar;C:\Turnkey
\tomcat\lib\jtds-1.2.jar;C:\ASG\ASGUMA\bin\lax.jar;C:\ASG\ASGUMA\bin\service.jar
;C:\ASG\ASGUMA\bin\umaadapters.jar;C:\ASG\ASGUMA\bin\umacomms.jar;C:\ASG\ASGUMA\
bin\umacomponents.jar;C:\ASG\ASGUMA\bin\umadataflow.jar;C:\ASG\ASGUMA\bin\umadat
aobjects.jar;C:\ASG\ASGUMA\bin\umademo.jar;C:\ASG\ASGUMA\bin\umadesigner.jar;C:\
ASG\ASGUMA\bin\umafaces.jar;C:\ASG\ASGUMA\bin\umafederation.jar;C:\ASG\ASGUMA\bi
n\umainstall.jar;C:\ASG\ASGUMA\bin\umaitemdata.jar;C:\ASG\ASGUMA\bin\umaprocesso
rs.jar;C:\ASG\ASGUMA\bin\umarepository.jar;C:\ASG\ASGUMA\bin\umaresources.jar;C:
\ASG\ASGUMA\bin\umarunner.jar;C:\ASG\ASGUMA\bin\umasecurity.jar;C:\ASG\ASGUMA\bi
n\umaservice.jar;C:\ASG\ASGUMA\bin\umaui.jar;C:\ASG\ASGUMA\bin\umautil.jar;C:\AS
G\ASGUMA\bin\umawebservice.jar;C:\Program Files\Microsoft Visual Studio\VC98\Inc
lude;C:\Program Files\Microsoft Visual Studio\VC98\Bin;C:\ASG\ASGUMA\bin\umawidg
et.jar;
 NMAKE_WINVER = 0x0400
  winsocklibs = ws2_32.lib mswsock.lib
    JAVA_HOME = C:\Program Files\Java\jdk1.5.0_14
         link = link
       PASCAL = pl
    dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll
    linkdebug = $(ldebug)
    conlflags = $(lflags) -subsystem:console,$(APPVER)
    TNS_ADMIN = C:\instantclient-basic-win32-10.2.0.4\instantclient_10_2
    guilflags = $(lflags) -subsystem:windows,$(APPVER)
    savlflags = $(lflags) -subsystem:windows,$(APPVER) -entry:WinMainCRTStartup
           cc = cl
       QTJAVA = C:\Program Files\Java\jre1.6.0_06\lib\ext\QTJava.zip
    olelibsmt = ole32.lib uuid.lib oleaut32.lib $(guilibsmt)
    conlibsmt = $(libcmt) $(baselibs)
           hc = hcrtf -xn
       WINDIR = C:\WINDOWS
       APPVER = 4.0
VS80COMNTOOLS = C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\
VS71COMNTOOLS = C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools
\
    guilibsmt = $(libcmt) $(winlibs)
    psxlflags = $(lflags) -subsystem:posix -entry:__PosixProcessStartup
           rc = rc
      libcdll = msvcrt.lib oldnames.lib
          LIB = C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\
;C:\Program Files\SQLXML 4.0\bin\
USERDNSDOMAIN = asg.com
   CLIENTNAME = Console
      rcflags = /r
       PROMPT = $P$G
          CPP = cl
          FOR = fl32
          CPU = i386
                $(PROCESSOR_ARCHITECTURE)
      olelibs = ole32.lib uuid.lib oleaut32.lib $(guilibs)
      conlibs = $(libc) $(baselibs)
      ccommon = -c -W3 -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo
FP_NO_HOST_CHECK = NO
      guilibs = $(libc) $(winlibs)
          TMP = C:\DOCUME~1\rupeshv\LOCALS~1\Temp
          CXX = cl
   ORACLE_SID = 10.30.0.95
   USERDOMAIN = ASG
      winlibs = $(baselibs) user32.lib gdi32.lib comdlg32.lib winspool.lib
      APPDATA = C:\Documents and Settings\rupeshv\Application Data
   ole2libsmt = $(olelibsmt)
      optlibs =
      MAKEDIR = E:\hook\hk\E2EHook\hook


INFERENCE RULES:

.asm.exe:
        commands:       $(AS) $(AFLAGS) $*.asm

.asm.obj:
        commands:       $(AS) $(AFLAGS) /c $*.asm

.c.exe:
        commands:       $(CC) $(CFLAGS) $<

.c.obj:
        commands:       $(CC) $(CFLAGS) /c $<

.cpp.exe:
        commands:       $(CPP) $(CPPFLAGS) $<

.cpp.obj:
        commands:       $(CPP) $(CPPFLAGS) /c $<

.cxx.exe:
        commands:       $(CXX) $(CXXFLAGS) $<

.cxx.obj:
        commands:       $(CXX) $(CXXFLAGS) /c $<

.bas.obj:
        commands:       $(BC) $(BFLAGS) $*.bas;

.cbl.exe:
        commands:       $(COBOL) $(COBFLAGS) $*.cbl, $*.exe;

.cbl.obj:
        commands:       $(COBOL) $(COBFLAGS) $*.cbl;

.f.exe:
        commands:       $(FOR) $(FFLAGS) $*.f

.f.obj:
        commands:       $(FOR) /c $(FFLAGS) $*.f

.f90.exe:
        commands:       $(FOR) $(FFLAGS) $*.f90

.f90.obj:
        commands:       $(FOR) /c $(FFLAGS) $*.f90

.for.exe:
        commands:       $(FOR) $(FFLAGS) $*.for

.for.obj:
        commands:       $(FOR) /c $(FFLAGS) $*.for

.pas.exe:
        commands:       $(PASCAL) $(PFLAGS) $*.pas

.pas.obj:
        commands:       $(PASCAL) /c $(PFLAGS) $*.pas

.rc.res:
        commands:       $(RC) $(RFLAGS) /r $*

.SUFFIXES: .exe .obj .asm .c .cpp .cxx .bas .cbl .f .f90 .for .pas .res .rc

TARGETS:

hooks32.res:
        flags:
        dependents:     hooks32.rc hooks32.h
        commands:       $(rc) $(rcvars) -r hooks32.rc

hooks32.exp:
        flags:
        dependents:     hooks32.obj hooks32.def
        commands:          $(implib) -machine:$(CPU)      -def:hooks32.def
         hooks32.obj ptdlgs.obj ptprint.obj ptfind.obj hooksdll.obj      -out:ho
oks32.lib

all:
        flags:
        dependents:     hooks32.exe hooksdll.dll
        commands:

hooksdll.lib:
        flags:
        dependents:     hooksdll.obj hooksdll.def hooksdll.rbj
        commands:          $(implib) -machine:$(CPU)      -def:hooksdll.def
         hooksdll.obj    -out:hooksdll.lib

hooksdll.obj:
        flags:
        dependents:     hooksdll.c hooks32.h
        commands:       $(cc) $(cflags) $(cvars) $(cdebug) hooksdll.c

hooksdll.dll:
        flags:
        dependents:     hooksdll.obj hooksdll.def hooksdll.lib
        commands:          $(link) $(linkdebug) MSVCRT.LIB /NODEFAULTLIB   -base
:0x1C000000   -dll             -entry:LibMain$(DLLENTRY)         -out:hooksdll.d
ll       hooksdll.exp hooksdll.obj hooksdll.rbj  $(guilibsdll)

hooksdll.rbj:
        flags:
        dependents:     hooksdll.res
        commands:       cvtres -$(CPU) hooksdll.res -o hooksdll.rbj

hooks32.obj:
        flags:
        dependents:     hooks32.c hooks32.h
        commands:       $(cc) $(cflags) $(cvars) $(cdebug) hooks32.c

hooks32.rbj:
        flags:
        dependents:     hooks32.res
        commands:       cvtres -$(CPU) hooks32.res -o hooks32.rbj

hooksdll.res:
        flags:
        dependents:     hooksdll.rc
        commands:       $(rc) $(rcvars) -r hooksdll.rc

hooks32.exe:
        flags:
        dependents:     hooks32.obj hooksdll.dll hooksdll.lib hooks32.rbj
                        hooks32.def
        commands:       $(link) $(linkdebug) MSVCRT.LIB  $(guiflags)   -out:hook
s32.exe  /ENTRY:mainCRTStartup  hooks32.obj hooksdll.lib hooks32.rbj  $(guilibs)



        cl -c -W3 -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -D_X86_=1 -D_WINNT -
D_WIN32_WINNT=0x0400 -D_WIN32_IE=0x0300 -DWINVER=0x0400 -DWIN32  -D_WIN32 -Z7 -O
d hooks32.c
NMAKE : fatal error U1077: 'cl' : return code '0xc0000135'
Stop.
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 24178987
It looks as if you have to pass the target with call of the nmake e. g.

      nmake hooks32.exe

most makefiles have a default so that the make a complete rebuild if no target was given.

Did you try to open the makefile in Visual Studio? You probably could make the build then from the IDE and it would show you all targets in the project tree (don't know exactly cause I never used makefiles from the IDE).

0
 
LVL 2

Author Comment

by:rupvis
ID: 24181796
Now able to compile and build the project. All i had to do was delete the .obj and .exe file to help nmake compile and rebuild the project.
All help is greatly appreciated.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question