【问题标题】:how to add library in makefile for verix如何在makefile中为verix添加库
【发布时间】:2017-02-28 21:16:46
【问题描述】:

我想使用 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

我该如何解决这个错误?

【问题讨论】:

    标签: batch-file makefile point-of-sale verifone


    【解决方案1】:

    所以,在我看来,你的 bat 文件有很多 cmets (@rem),它还设置了几个变量 (@set),但大部分工作将在行中完成

    nmake /f app.mak 
    

    这将引用一个名为app.mak 的不同文件。这就是魔法发生的地方,你需要编辑一些东西让nmake知道如何编译和链接utils.h。我建议您查看c2.com/cgi/wiki?UsingNmake 了解更多详情。

    如您所知,就所有意图和目的而言,make 文件都是您编写的程序。当它运行时,它会构建 VeriFone 应用程序(或您正在处理的任何其他程序)。因此,您可以做很多事情,如果您希望 nmake 实际构建您的程序,您必须做一些事情。我认为最好的帮助方法是分享我的 make 文件的一部分。请注意,这只是作为 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 Studio 设置为在启动构建时传递给 NMAKE 的东西,它基于我的解决方案配置。从技术上讲,我有 1 个 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 终端编译的任何人来说,这里的重要部分是 CompilerCompatibility,它设置了一个 -p 标志(对于 Verix V 必须关闭,对于 eVo 终端必须打开)。

    现在我们将迄今为止所做的一切合并为 2 个变量:

    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
    

    ...并构建 .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 文件中的最后一步。接下来,我会告诉一个人如何进行链接,但这是第二步到最后一步,以此类推。

    如果您仍需要更多信息,请访问我提供的链接——它比我更权威,并且包含很多我可能错过的细节。不过,希望这足以让您继续前进。

    【讨论】:

    • 您只有一个用于创建 .out 文件的文件吗?你点击 .MAK 文件,输出是 .out 文件?
    • 我有错误nmake is not recognized as an internal or external command
    • 听起来nmake 所在的目录不在您的路径中(我假设您在Windows 机器上)。我的在我的 %EVOTOOLS% 中(当前解析为 C:\eVoAps\Tools\1.3.0)。确保您的 nMake 所在的任何目录都是系统 PATH 的一部分。
    • 为了回答你的其他问题,我使用 Visual Studio 作为我的 IDE,所以当我想构建时,我只需点击“构建”按钮。但是,我必须进行所有设置才能做到这一点。我在这里讨论:stackoverflow.com/a/39988351/1467396 请注意,第 3-1 行以Configuration=$(Configuration) 结尾。这就是我们在上面的 make 文件中设置“TerminalType”的方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-13
    • 1970-01-01
    • 2016-12-19
    • 1970-01-01
    • 2015-04-07
    • 2011-05-28
    • 2012-02-15
    相关资源
    最近更新 更多