我想使用makefile来创建我的应用程序和.out文件,并在我的verifone vx520中使用它。我有用于创建makeapp.bat文件的.out文件,但是当我运行它时,会得到以下错误:NMAKE : fatal error U1073: don't know how to make 'utils.h',这是makeapp.bat文件:
@goto Begin
:Begin
@set OLDPATH=%PATH%
@rem set VRXSDKS to the Verix V SDK directory
@set VRXSDK=C:\eVoAps\SDK\1.2.0\VRXSDK
@rem Set RVCTDIR to RVDS2.2
@set RVCTDIR=C:\Program Files\ARM\RVCT\Programs\2.2\349\win_32-pentium
@rem or, Set RVCTDIR to RVDS2.1
@rem set RVCTDIR=C:\Program Files\ARM\RVCT\Programs\2.0.1\277\win_32-pentium
@set PATH=%VRXSDK%\bin\;%RVCTDIR%;%OLDPATH%
@rem use app.mak to buid application
nmake /f app.mak
@rem or, use vrxcc directly here to build a simple application
@rem %VRXSDK%\bin\vrxcc app.c
@set PATH=%OLDPATH%
@set RVCTDIR=
pause我怎样才能解决这个错误?
发布于 2016-10-24 23:45:54
因此,在我看来,这里的bat文件有很多注释(@rem),它还设置了几个变量(@set),但是大部分工作将在行中完成
nmake /f app.mak 它将引用一个名为app.mak的不同文件。这就是魔术发生的地方,也是你需要编辑一些东西,让nmake知道如何编译和链接utils.h的地方。我建议您查看c2.com/cgi/wiki?UsingNmake以获得更多详细信息。
如您所知,make文件是您所编写的程序。当它运行时,它构建了VeriFone应用程序(或其他您正在开发的程序)。因此,你可以做很多事情,如果你想让nmake实际构建你的程序,你必须做一些事情。我认为最好的办法是分享我的制作文件的一部分。请注意,这只是从一个示例VeriFone项目的模板开始的。
我的一开始只是声明变量、路径等,如下所示:
ProjectName = TestProject
# ****** PATHS ******
# Includes
SDKIncludes = -I$(EVOSDK)\include
ACTIncludes = -I$(EVOACT)include
VCSIncludes = -I$(EVOVCS)include
#Libraries
ACTLibraries = $(EVOACT)OutPut\RV\Files\Static\Release
# App Paths
AppIncludes = .\include
SrcDir = .\source
ObjDir = .\obj
OutDir = .\Output\$(TerminalType)\$(VMACMode)\Files
ResDir = .\Resource注意,TerminalType是我将Visual设置为在启动构建时传递给NMAKE的东西,它是基于我的解决方案配置的。从技术上讲,我有一个make文件调用另一个文件,外部文件是这样设置的:TerminalType=$(Configuration)。您将在下面再次看到这个变量,以及其他一些类似的变量。
接下来,我定义了一些编译器选项。
# Switch based on terminal type
!IF "$(TerminalType)"=="eVo"
CompilerCompatibility=-p
DefineTerminalType = -DEVO_TERMINAL
!ELSE
CompilerCompatibility=
DefineTerminalType = -DVX_TERMINAL
!ENDIF-D标志定义了代码中的内容,就像我做了#define一样。这对于打开或关闭部件非常有用,这取决于我正在编译的内容。除非你打算这么做,否则你不需要自己去做。对于任何为eVo终端编译的人来说,这里最重要的部分是设置-p标志的CompilerCompatibility (必须为Verix关闭,必须为eVo终端打开)。
现在,我们将到目前为止所做的所有工作合并为两个变量:
Includes = -I$(AppIncludes) $(SDKIncludes) $(ACTIncludes) $(VMACIncludes) $(VCSIncludes)
COptions =$(CompilerCompatibility) $(DefineTerminalType) 好的,下面是我怀疑您正在被绊倒的部分:我们需要定义我们的依赖关系,我喜欢这样做:
# Dependencies
AppObjects = \
$(ObjDir)\$(ProjectName).o \
$(ObjDir)\Base.o \
$(ObjDir)\UI.o \
$(ObjDir)\Comm.o
Libs = $(ACTLibraries)\act2000.a如果我们愿意的话,这一切都可以在同一条线上进行。每一行末尾的\只意味着我们要打破单行,这是在这里完成的可读性。否则,它看起来会是这样的:
AppObjects = $(ObjDir)\$(ProjectName).o $(ObjDir)\Base.o $(ObjDir)\UI.o $(ObjDir)\Comm.o
Libs = $(ACTLibraries)\act2000.a好的,所以这个AppObjects将在我们进行链接时使用。但是,首先,我还想告诉NMAKE运行文件签名程序,然后将文件复制到我想要的位置。
# Sign the file(s). Tell nMake that we also
# will be creating the resource file and compiling the actual code...
# NOTE: (the indentations seen below are required for nMake to work properly)
# pseudoOut depends on TestProject.res and TestProject.out.
# If TestProject.res or TestProject.out have changed more recently than pseudoOut,
# then run commands vrxhdr..., filesignature..., and move...
!if "$(VMACMode)"=="Multi"
pseudoOut : $(ResDir)\$(ProjectName).res $(OutDir)\$(ProjectName).out
!else
pseudoOut : $(OutDir)\$(ProjectName).out
!endif
# This calls vrxhdr: the utility program that fixes the executable program’s header required to load and run the program.
# Vrxhdr is needed when you want to move a shared library around on the terminal.
$(EVOSDK)\bin\vrxhdr -s 15000 -h 5000 $(OutDir)\$(ProjectName).out
# do the signing using the file signature tool and the .fst file associated with this TerminalType.
"$(VSFSTOOL)\filesignature" $(TerminalType)$(VMACMode).fst -nogui
@echo __________________ move files to out directory __________________
# rename the .p7s file we just created
move $(OutDir)\$(ProjectName).out.p7s $(OutDir)\$(ProjectName).p7s
!if "$(VMACMode)"=="Multi"
copy $(ResDir)\imm.ini $(OutDir)\imm.ini
copy $(ResDir)\$(ProjectName).INS $(OutDir)\$(ProjectName).INS
copy $(ResDir)\$(ProjectName).res $(OutDir)\$(ProjectName).res
!endif
@echo *****************************************************************现在,让我们定义我们将如何进行链接:
# Link object files
$(OutDir)\$(ProjectName).out : $(AppObjects)
$(EVOSDK)\bin\vrxcc $(COptions) $(AppObjects) $(Libs) -o $(OutDir)\$(ProjectName).out...and构建.res文件..。
#This will actually build the .res file. (We only said we were going to do it above)
!if "$(VMACMode)"=="Multi"
# compile resource file
$(ResDir)\$(ProjectName).res : $(ResDir)\$(ProjectName).rck
# SET INCLUDE=$(INCLUDE);$(EVOVMAC)\include;$(EVOVMAC)\template --> I put this into my include path for the project, instead
$(EVOTOOLS)rck2 -S$(ResDir)\$(ProjectName) -O$(ResDir)\$(ProjectName) -M
!endif现在我们可以实际运行编译:
# Compile modules --> -c = compile only, -o = output file name, -e"-" => -e redirect error output from sub-tools to... "-" to stdout. (These are all then redirected via pipe | )
# For more details, see Verix_eVo_volume 3, page 59
$(ObjDir)\$(ProjectName).o : $(SrcDir)\$(ProjectName).c
!IF !EXISTS($(OutDir))
!mkdir $(OutDir)
!ENDIF
-$(EVOSDK)\bin\vrxcc -c $(COptions) $(Includes) -o $(ObjDir)\$(ProjectName).o $(SrcDir)\$(ProjectName).c -e"-" | "$(EVOTOOLS)fmterrorARM.exe"
$(ObjDir)\Base.o : $(SrcDir)\Base.c
$(EVOSDK)\bin\vrxcc -c $(COptions) $(Includes) -o $(ObjDir)\base.o $(SrcDir)\Base.c -e"-" | "$(EVOTOOLS)fmterrorARM.exe"
$(ObjDir)\UI.o : $(SrcDir)\UI.c
$(EVOSDK)\bin\vrxcc -c $(COptions) $(Includes) -o $(ObjDir)\UI.o $(SrcDir)\UI.c -e"-" | "$(EVOTOOLS)fmterrorARM.exe"
$(ObjDir)\Comm.o : $(SrcDir)\Comm.c
$(EVOSDK)\bin\vrxcc -c $(COptions) $(Includes) -o $(ObjDir)\Comm.o $(SrcDir)\Comm.c -e"-" | "$(EVOTOOLS)fmterrorARM.exe"这是最后一句-没有其他的大张旗鼓或什么的-你。
我想指出一些你可能已经注意到的事情,但当我开始做这一切的时候,我想做一个循环:我们要做所有的事情。如果我告诉一个人如何构建这个项目,我会首先告诉他们如何将所有内容编译成它的.o文件,但这是make文件的最后一步。接下来,我会告诉一个人如何做链接,但这是第二步到最后一步,等等。
如果你还需要更多的信息,请访问我包含的链接--它比我更权威,并且包含了很多我可能错过的细节。希望这足以让你继续前进。
https://stackoverflow.com/questions/40127882
复制相似问题