本文介绍了如何在makefile中为verix添加库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用makefile来创建我的应用程序和.out文件,并在Verifone vx520中使用它.我有用于创建.out文件的makeapp.bat,但是在运行它时出现此错误:NMAKE : fatal error U1073: don't know how to make 'utils.h'这是makeapp.bat文件:

I want to use makefile to create my app and .out file and use it in my verifone vx520.I have makeapp.bat for creating .out file but when I run it get this error: NMAKE : fatal error U1073: don't know how to make 'utils.h'and this is makeapp.bat file:

@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

我该如何解决该错误?

推荐答案

所以,在我看来,您的bat文件包含很多注释(@rem),并且还设置了多个变量(@set),但大部分的工作将在

So, it looks to me like your bat file here has lots of comments (@rem) and it also sets several variables (@set), but the bulk of the work will be done in the line

nmake /f app.mak

,它将引用另一个名为app.mak的文件.那就是魔术发生的地方,您需要在其中进行编辑以使nmake知道如何编译和链接utils.h.建议您查看 c2.com/cgi/wiki?UsingNmake 以获得更多详细信息.

which will reference a different file called app.mak. That's where the magic happens and it's where you will need to edit something to let nmake know how to compile and link utils.h. I suggest you look at c2.com/cgi/wiki?UsingNmake for more details.

如您所知,make文件出于所有目的和目的都是您编写的程序.运行时,它将构建VeriFone应用程序(或您正在使用的任何其他程序).这样,您可以做很多事情,如果您想让nmake实际构建程序,则必须做一些事情.我认为最好的解决方法是共享我的make文件的一部分.请注意,这只是从示例VeriFone项目的模板开始的.

As you know, a make file is, for all intents and purposes, a program that you write. When it runs, it builds the VeriFone app (or whatever other program you were working on). As such, there is a multitude of things you can do, some of which you must do if you want nmake to actually build your program. I think the best way to help out would be to share parts of my make file. Note that this started off as just a template from a sample VeriFone project.

我的开始只是声明变量,路径等,就像这样:

Mine starts off just declaring variables, paths, etc., like so:

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 Studio设置为在启动构建时传递给NMAKE的功能,它基于我的解决方案配置.从技术上讲,我有1个make文件调用另一个,而外部文件则这样设置:TerminalType=$(Configuration).您将在下面再次看到此变量以及其他两个相似的变量.

Note that TerminalType is something I have set Visual Studio to pass into NMAKE when it initiates a build and it is based on my solution configuration. Technically, I have 1 make file calling another and the outer one is setting it like this: TerminalType=$(Configuration). You'll see this variable again below as well as a couple others that are similar.

接下来,我定义一些编译器选项

Next, I define some compiler options

#  Switch based on terminal type
!IF "$(TerminalType)"=="eVo"
CompilerCompatibility=-p
DefineTerminalType = -DEVO_TERMINAL
!ELSE
CompilerCompatibility=
DefineTerminalType = -DVX_TERMINAL
!ENDIF

-D标志将代码中的内容定义为就像执行了#define一样.这对于根据我要编译的零件打开或关闭零件很有用.除非您打算这样做,否则您将不需要自己做.对于任何为eVo终端进行编译的人来说,重要的部分是CompilerCompatibility,它设置了-p标志(对于Verix V必须为关闭,对于eVo终端必须为打开).

The -D flag defines things in my code as if I had done a #define. This is useful for turning parts on or off depending one what I'm compiling for. Unless you plan to do that, you won't need to do it yourself. The important part here for anyone compiling for eVo terminals is the CompilerCompatibility which sets a -p flag (must be off for Verix V, must be on for for eVo terminals).

现在,我们将到目前为止已完成的所有工作合并为2个变量:

Now we consolidate everything we've done thus far into 2 variables:

Includes    = -I$(AppIncludes) $(SDKIncludes) $(ACTIncludes) $(VMACIncludes) $(VCSIncludes)
COptions    =$(CompilerCompatibility) $(DefineTerminalType)

好的,现在这是我怀疑您要尝试的部分:我们需要定义依赖项,我这样做是这样的:

OK, now here's the part I suspect you are tripping up on: we need to define our dependencies, which I do like so:

# Dependencies
AppObjects = \
        $(ObjDir)\$(ProjectName).o \
        $(ObjDir)\Base.o \
        $(ObjDir)\UI.o \
        $(ObjDir)\Comm.o

Libs =      $(ACTLibraries)\act2000.a

如果我们愿意的话,这可以全部排成一行.每行末尾的\只是意味着我们要打破这一行,以提高可读性.否则,它将如下所示:

This could all go on one line, if we wanted to. The \ at the end of each line just means we are breaking that single line up which is done here for readability. Otherwise, it would look like this:

AppObjects = $(ObjDir)\$(ProjectName).o $(ObjDir)\Base.o $(ObjDir)\UI.o $(ObjDir)\Comm.o

Libs = $(ACTLibraries)\act2000.a

确定,因此在进行链接时将使用此AppObjects.但是,首先,我还想告诉NMAKE运行文件签名程序,然后将文件复制到我想要的位置.

OK, so this AppObjects will be used when we do our linking. First, however, I also want to tell NMAKE to run the file signing program and then copy the files over where I want them.

#  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 *****************************************************************

现在让我们定义如何进行链接:

Now let's define how we will do the linking:

#  Link object files
$(OutDir)\$(ProjectName).out : $(AppObjects)
    $(EVOSDK)\bin\vrxcc $(COptions) $(AppObjects) $(Libs) -o $(OutDir)\$(ProjectName).out

...并构建.res文件...

...and build the .res file...

#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

现在我们可以实际运行编译了:

and now we can actually run the compilation:

#  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"

这是最后一行-没有其他声名狼藉或您拥有什么.

And that's the last line--there is no other fanfare or what-have-you.

我想指出一些您可能已经注意到的事情,但是当我开始进行所有这些操作时,让我陷入了循环:我们有点倒退了.如果我要告诉一个人如何构建项目,那么我首先要告诉他们如何将所有内容编译到它的.o文件中,但这是make文件中的最后一步.接下来,我要告诉一个人如何进行链接,但这是倒数第二个步骤,依此类推.

I would like to point something out that you may have noticed, but threw me for a loop when I was getting started on all of this: we kinda' do everything backwards. If I were telling a person how to build the project, I would start by telling them how to compile everything to it's .o file first, but that's the last step in a make file. Next, I would tell a person how to do the linking, but that's the 2nd to last step, and so on.

如果您仍然需要更多信息,请访问我包含的链接-它比我更具权威性,并且包含许多我可能错过的细节.希望这足以使您前进.

If you still need more info, visit the link I included--it's way more authoritative than I am and includes a lot of details I probably missed. Hopefully this is enough to get you going, though.

这篇关于如何在makefile中为verix添加库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:14