精华内容
下载资源
问答
  • 从DLL生成LIB

    2013-05-14 19:41:00
    从DLL生成LIB cheungmine 2013-5-14windows程序链接到一个动态链接库.dll时需要一个导入库.lib。遗憾的是这样的导入库很多时候是不存在的,那么就需要我们自己从.dll生成对应的导入库.lib。假设我们的windows程序为...

    从DLL生成LIB

    cheungmine

    2013-5-14

    windows程序链接到一个动态链接库.dll时需要一个导入库.lib。遗憾的是这样的导入库很多时候是不存在的,那么就需要我们自己从.dll生成对应的导入库.lib。假设我们的windows程序为WinApp.exe,它静态链接到一个动态库libABC.dll。我们在WinApp.exe的源代码中可以这样写:

    // (程序清单1)
    // WinApp.c
    //
    
    #include <windows.h>
    
    #include "C:/DEVPACK/LIBABC/include/ABCapi.h"
    # pragma comment(lib, "C:/DEVPACK/LIBABC/lib/libABC.lib");
    
    int main()
    {
        // 下面可以直接使用 LIBABC 的函数
        ABCInit();
        ABCAddValues(a, b);
        ABCUninit();
    
        exit(0);
    }
    但是问题是,我们手里只有libABC.dll和头文件。没有libABC.lib。这就需要我们从命令行工具生成出libABC.lib。从DLL生成LIB的过程是:DLL->DEF->LIB。需要生成一个叫做模块定义文件(.def)的中间文件。一个典型的模块定义文件(libABC.def)如下(程序清单2):
    LIBRARY libABC
    
    EXPORTS
        ABCInit
        ABCUninit
        ABCAddValues
        ...
    windows的vs系列开发工具提供了这个命令行dumpbin,它的调用方式是打开cmd,然后输入下面的命令:
    dumpbin /EXPORTS libABC.dll > libABC.def
    

    上面的命令执行后生成的libABC.def文件包含了对于生成LIB无用的信息,我们必须手工处理掉,然后才能带入下面的命令中生成LIB。假设我们已经把libABC.def处理成(程序清单2)的样子。接下来使用另外一个命令行工具,通过这个def文件生成LIB:

    lib /def:libABC.def /machine:i386 /out:libABC.dll

    总结下来,整个过程有3步:
    1)DLL->def
    2)处理def
    3)使用处理后的def->LIB

    整个过程在第2步不是自动化的,我曾经写过一个脚本完成第2步的自动化。后来发现MinGW提供了这样的工具:pexports。默认的MinGW没有安装pexports,你需要运行下面的命令在MinGW中安装:

    $ mingw-get install pexports
    于是,产生处理好的def的工作就变得非常简单:
    $ pexports libABC.dll > libABC.def
    无论是dumpbin还是lib这2个命令都需要VS的运行环境。因此必须先设置环境变量,通过运行一个在%VS??COMNTOOLS%的路径下的批处理文件vsvars32.bat(??表示版本号,可以查看windows环境变量得到这个信息),来完成VS环境变量设置。过程就是打开windows cmd,输入下面的命令:
    %VS100COMNTOOLS%vsvars32.bat
    最后我把整个处理过程写成了python脚本,这个脚本执行起来特别简单,打开MinGW命令行,进入libABC.dll所在的目录,输入下面的命令:
    $ python mklib-win32.py libABC
    或者
    $ python mklib-win32.py libABC.dll

    最后,我把mklib-win32.py贴出来,以飨读者:

    #!/usr/bin/python
    # filename: mklib-win32.py
    # make import x86_32 import-lib from windows win32 dll
    # author: cheungmine@gmail.com
    # date: 2013-5
    # version: 0.1
    #
    # MinGW:
    #   $ python build-win32.py target_dll
    #   $ python build-win32.py libtiff-5.dll
    #   $ python build-win32.py libtiff-5
    #   $ python build-win32.py tiff-5
    #   $ python build-win32.py c:/path/to/libtiff-5
    # ERROR: $ python build-win32.py c:\path\to\libtiff-5
    #
    # file operation:
    # import shutil
    #
    ## copy file:
    #   shutil.copy(myfile, tmpfile)
    #
    ## copy time of file:
    #   shutil.copy2(myfile, tmpfile)
    #
    ## copy file dir tree, the 3rd parameter means:
    ##   True: symbol link
    ##   False: use phyical copy
    #   shutil.copytree(root_of_tree, destination_dir, True)
    ###############################################################################
    
    import os
    import platform
    import time
    import getopt
    import optparse
    import sys
    import string
    
    ###############################################################################
    # get installed VS???COMNTOOLS environment:
    ###############################################################################
    def get_vspath():
      _vspath = os.getenv('VS110COMNTOOLS')
      if not _vspath:
        _vspath = os.getenv('VS100COMNTOOLS')
        if not _vspath:
          _vspath = os.getenv('VS90COMNTOOLS')
          if not _vspath:
            _vspath = os.getenv('VS80COMNTOOLS')
            if not _vspath:
              print "VS??COMNTOOLS not found"
              sys.exit()
            else:
              print "VS80COMNTOOLS =", _vspath
          else:
            print "VS90COMNTOOLS =", _vspath
        else:
          print "VS100COMNTOOLS =", _vspath
      else:
        print "VS110COMNTOOLS =", _vspath
      return _vspath
    
    ###############################################################################
    # step (1): create a windows module definition: target_lib.def
    #   MSCMD:
    #     > dumpbin /EXPORTS target_lib.dll > ~target_lib.def
    #   or MinGW:
    #     $ pexports target_lib.dll > target_lib.def
    # step (2): use this target_lib.def to create module import file: target_lib.lib
    #   MSCMD:
    #     > lib /def:target_lib.def /machine:i386 /out:target_lib.lib
    ###############################################################################
    def make_lib(workdir, tgtname):
      print "[2-1] create a windows module definition: lib%s.def" % tgtname
      dump_def = 'cd "%s"&pexports lib%s.dll > lib%s.def' % \
        (work_dir, tgtname, tgtname)
      ret = os.system(dump_def)
      if ret == 0:
        print "[2-2] use (lib%s.def) to create import module: lib%s.lib" % (tgtname, tgtname)
        lib_cmd = 'cd "%s"&lib /def:lib%s.def /machine:i386 /out:lib%s.lib' % (workdir, tgtname, tgtname)
        cmds = 'cd "%s"&vsvars32.bat&%s&cd "%s"' % (vs_path, lib_cmd, cwd_path)
        ret = os.system(cmds)
        if ret == 0:
          print "INFO: mklib (%s/lib%s.lib) success." % (cwd_path, tgtname)
          return 0;
        else:
          print "ERROR: mklib (%s/lib%s.lib) failed." % (cwd_path, tgtname)
          return (-2)
      else:
        print "ERROR: mklib (%s/lib%s.def) failed." % (cwd_path, tgtname)
        return (-1);
    
    ###############################################################################
    # current directory:
    cwd_path = os.getcwd()
    vs_path = get_vspath()
    
    work_dir = "./"
    
    # lib name == parent folder name
    target_dll = "ERROR_dll_not_found"
    
    if sys.argv.__len__() == 1:
      work_dir, target_dll = os.path.split(cwd_path)
    elif sys.argv.__len__() == 2:
      work_dir = os.path.dirname(sys.argv[1])
      target_dll = os.path.basename(sys.argv[1])
    else:
      print "ERROR: invalid argument"
      sys.exit(-1)
    
    if target_dll[0:3] == "lib":
      target_dll = target_dll[3:]
    tgtname, extname = os.path.splitext(target_dll)
    
    if extname != ".dll":
      tgtname = target_dll
    
    if work_dir == "":
      work_dir = cwd_path
    
    print "working directory:", work_dir
    print "======== make import (lib%s.lib) from (lib%s.dll) ========" % \
      (tgtname, tgtname)
    
    make_lib(work_dir, tgtname)
    
    sys.exit(0)
    

    由于近期开发windows x64程序,因此需要生成64位的DLL对应的LIB,于是我又在mklib-win32.py的基础上完成了mklib-win64.py的脚本,具体原理我就不说了,读者注意脚本之中的细微之处不难理解:

    #!/usr/bin/python
    # filename: mklib-win64.py
    # make import x86_64 import-lib from windows x64 dll
    # author: cheungmine@gmail.com
    # date: 2013-5
    # version: 0.1
    #
    # MinGW:
    #   $ python build-win64.py target_dll
    #   $ python build-win64.py libtiff-5.dll
    #   $ python build-win64.py libtiff-5
    #   $ python build-win64.py tiff-5
    #   $ python build-win64.py c:/path/to/libtiff-5
    # ERROR: $ python build-win64.py c:\path\to\libtiff-5
    #
    # file operation:
    # import shutil
    #
    ## copy file:
    #   shutil.copy(myfile, tmpfile)
    #
    ## copy time of file:
    #   shutil.copy2(myfile, tmpfile)
    #
    ## copy file dir tree, the 3rd parameter means:
    ##   True: symbol link
    ##   False: use phyical copy
    #   shutil.copytree(root_of_tree, destination_dir, True)
    ###############################################################################
    
    import os
    import platform
    import time
    import getopt
    import optparse
    import sys
    import string
    
    ###############################################################################
    # get installed VS???COMNTOOLS environment:
    ###############################################################################
    def get_vspath():
      _vspath = os.getenv('VS110COMNTOOLS')
      if not _vspath:
        _vspath = os.getenv('VS100COMNTOOLS')
        if not _vspath:
          _vspath = os.getenv('VS90COMNTOOLS')
          if not _vspath:
            _vspath = os.getenv('VS80COMNTOOLS')
            if not _vspath:
              print "VS??COMNTOOLS not found"
              sys.exit()
            else:
              print "VS80COMNTOOLS =", _vspath
          else:
            print "VS90COMNTOOLS =", _vspath
        else:
          print "VS100COMNTOOLS =", _vspath
      else:
        print "VS110COMNTOOLS =", _vspath
      return _vspath
    
    ###############################################################################
    # step (1): create a windows module definition: target_lib.def
    #   MSCMD:
    #     > dumpbin /EXPORTS target_lib.dll > ~target_lib.def
    #   or MinGW:
    #     $ pexports target_lib.dll > target_lib.def
    # step (2): use this target_lib.def to create module import file: target_lib.lib
    #   MSCMD:
    #     > lib /def:target_lib.def /machine:amd64 /out:target_lib.lib
    ###############################################################################
    def make_lib(workdir, tgtname):
      print "[2-1] create a windows module definition: lib%s.def" % tgtname
      dump_def = 'cd "%s"&pexports lib%s.dll > lib%s.def' % \
        (work_dir, tgtname, tgtname)
      ret = os.system(dump_def)
      if ret == 0:
        print "[2-2] use (lib%s.def) to create import module: lib%s.lib" % (tgtname, tgtname)
        lib_cmd = 'cd "%s"&lib /def:lib%s.def /machine:amd64 /out:lib%s.lib' % (workdir, tgtname, tgtname)
        cmds = 'cd "%s"&vcvarsall.bat x86_amd64&%s&cd "%s"' % (vs_path, lib_cmd, cwd_path)
        ret = os.system(cmds)
        if ret == 0:
          print "INFO: mklib (%s/lib%s.lib) success." % (cwd_path, tgtname)
          return 0;
        else:
          print "ERROR: mklib (%s/lib%s.lib) failed." % (cwd_path, tgtname)
          return (-2)
      else:
        print "ERROR: mklib (%s/lib%s.def) failed." % (cwd_path, tgtname)
        return (-1);
    
    ###############################################################################
    # current directory:
    cwd_path = os.getcwd()
    vs_path = get_vspath() + "..\\..\\VC\\"
    work_dir = "./"
    
    # lib name == parent folder name
    target_dll = "ERROR_dll_not_found"
    
    if sys.argv.__len__() == 1:
      work_dir, target_dll = os.path.split(cwd_path)
    elif sys.argv.__len__() == 2:
      work_dir = os.path.dirname(sys.argv[1])
      target_dll = os.path.basename(sys.argv[1])
    else:
      print "ERROR: invalid argument"
      sys.exit(-1)
    
    if target_dll[0:3] == "lib":
      target_dll = target_dll[3:]
    tgtname, extname = os.path.splitext(target_dll)
    
    if extname != ".dll":
      tgtname = target_dll
    
    if work_dir == "":
      work_dir = cwd_path
    
    print "working directory:", work_dir
    print "======== make import (lib%s.lib) from (lib%s.dll) ========" % \
      (tgtname, tgtname)
    
    make_lib(work_dir, tgtname)
    
    sys.exit(0)
    

    我做了个试验,就是用MinGW构建sqlite3,默认没有构建出我需要的dll,于是我首先进入sqlite3.o所在的目录,运行下面的命令手工构建出dll:

    $ gcc -shared -fPIC sqlite3.o -o libsqlite3.dll -s
    然后用mklib-win64.py生成lib文件:

    $ python mklib-win64.py libsqlite3.dll
    最后生成了64位版本的libsqlite3.lib,通过VS2010编写的程序测试,完全正确。

    #include "C:/DEVPACK/MinGW/local64/dst/sqlite3/include/sqlite3.h"
    # pragma comment(lib, "C:/DEVPACK/MinGW/local64/dst/sqlite3/lib/libsqlite3.lib");
    
    ......
    
    void test_sqlite3()
    {
      int ret;
      sqlite3       *dbconn;
      sqlite3_stmt  *stmt;
      char          *errmsg;
    
      ret = sqlite3_open_v2("C:/workspace/antelope/test.db", &dbconn,
        SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX |
        SQLITE_OPEN_SHAREDCACHE, 0);
    
      if (ret != SQLITE_OK) {
        fprintf(stdout, "ERROR: sqlite3_open_v2() error (%d).\n",
          ret);
      }
    }
    

    于是,便有了此文!


    展开全文
  • 从dll生成lib

    2010-03-28 19:21:00
    过去一段时间断断续续在搞dll,最简单那种。一直疑虑有多少内容可以被反汇编出来。come across 这个题目,算是个开始。备忘 1。dumpbin /exports example.dll > example.def 2。 修改example.def 为def格式,如...

    过去一段时间断断续续在搞dll,最简单那种。一直疑虑有多少内容可以被反汇编出来。come across 这个题目,算是个开始。备忘

     

    1。dumpbin   /exports   example.dll   >   example.def 

     

    2。 修改example.def 为def格式,如(例子来自网上):

    TM_ClearDecoderBuff@4 @1           

    TM_CloseDecoder@4 @2           

    TM_DecodePicture@4 @3      

     

    3。 lib   /def:yourdll.def   /machine: IX86   /out:yourdll.lib 

     

    对第一步,用工具也可,只要能看到dll的函数列表。比如VC的depends

     

    以下copy:

    注意的是当有些动态库DUMPBIN的只有函数名,无"@nn"的参数格式,如C++Builder写的DLL,输出就只有函数名符号,链接时就会报错:   error   LNK2002:unresolved   external   symbol   "functionname@nn"   提示程序中引入的函数符号无法识别,这时只要将DEF文件中相应的函数名称改为functionname@nn方式,重新建立   LIB,重新链接即可.   

     

     

    展开全文
  • 从DLL生成LIB文件

    千次阅读 2018-04-27 17:48:55
    设置VS2015运行环境 在开始菜单打开Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 x64 Cross Tools Command Prompt 切换到DLL所在目录 ...生成DEF文件 dumpbin...

    设置VS2015运行环境

    在开始菜单打开Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 x64 Cross Tools Command Prompt

    切换到DLL所在目录

    在命令窗口输入 cd /d "你的DLL目录"回车切换到对应目录。

    生成DEF文件

    dumpbin /exports zmotion_x64.dll> zmotion_x64.def

    生成的文件如下:

    Microsoft (R) COFF/PE Dumper Version 14.00.24210.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    
    Dump of file zmotion_x64.dll
    
    File Type: DLL
    
      Section contains the following exports for zmotion.dll
    
        00000000 characteristics
        54101CA1 time date stamp Wed Sep 10 17:40:49 2014
            0.00 version
               1 ordinal base
             136 number of functions
             136 number of names
    
        ordinal hint RVA      name
    
            134    0 0000CA20 DllCanUnloadNow
            135    1 0000C9C0 DllGetClassObject
            136    2 0000CA60 DllRegisterServer
              1    3 00003FB0 ZMC_BreakAdd
              2    4 00004160 ZMC_BreakClear
              3    5 00004090 ZMC_BreakDel
              4    6 00001EB0 ZMC_CalStringHash
              5    7 000039C0 ZMC_CancelOnline
              6    8 00001F80 ZMC_Check3File
              7    9 00002C50 ZMC_CheckFirmWare
              8    A 000034E0 ZMC_CheckProgramSyntax
              9    B 00003190 ZMC_ClearLog
             10    C 00001450 ZMC_Close
             11    D 000020B0 ZMC_Delete3File
             12    E 00003300 ZMC_DeleteFile
             13    F 000016F0 ZMC_DirectCommand
             14   10 00003260 ZMC_DownFile
             15   11 00002DA0 ZMC_DownFirmWare
             16   12 00003280 ZMC_DownMemFile
             17   13 000018A0 ZMC_DownMemZar
             18   14 000019E0 ZMC_DownMemZarToRamAndRun
             19   15 000017A0 ZMC_DownZar
             20   16 000018D0 ZMC_DownZarToRamAndRun
             21   17 00003E80 ZMC_EnumArray
             22   18 00003C80 ZMC_EnumChildCard
             23   19 00003E80 ZMC_EnumLabel
             24   1A 00003D60 ZMC_EnumLocal
             25   1B 00003E80 ZMC_EnumPara
             26   1C 00003E80 ZMC_EnumSub
             27   1D 00003E80 ZMC_EnumVar
             28   1E 00004530 ZMC_Execute
             29   1F 00001650 ZMC_ExecuteGetReceive
             30   20 000016C0 ZMC_ExecuteGetRemainBuffSpace
             31   21 00004430 ZMC_ExecuteNoAck
             32   22 00001610 ZMC_ExecuteWaitDown
             33   23 00004210 ZMC_FastOpen
             34   24 00002020 ZMC_FindFirst3File
             35   25 00003200 ZMC_FindFirstFile
             36   26 00002050 ZMC_FindNext3File
             37   27 00003230 ZMC_FindNextFile
             38   28 00002160 ZMC_FlashReadf
             39   29 000020F0 ZMC_FlashWritef
             40   2A 000026F0 ZMC_GetAIn
             41   2B 000034F0 ZMC_GetAxisFeatures
             42   2C 000025C0 ZMC_GetAxisStates
             43   2D 000015E0 ZMC_GetAxises
             44   2E 00002270 ZMC_GetChipId
             45   2F 00002230 ZMC_GetClientId
             46   30 00001570 ZMC_GetConnectString
             47   31 00001540 ZMC_GetConnectType
             48   32 00002F40 ZMC_GetControllerIDDate
             49   33 00002080 ZMC_GetCur3File
             50   34 00002200 ZMC_GetCurIpAddr
             51   35 000027A0 ZMC_GetDaOut
             52   36 000034B0 ZMC_GetErrcodeDescription
             53   37 00002250 ZMC_GetError
             54   38 00003BD0 ZMC_GetFileState
             55   39 00002260 ZMC_GetHardId
             56   3A 00002480 ZMC_GetIn
             57   3B 000029A0 ZMC_GetInAll
             58   3C 000031D0 ZMC_GetMac
             59   3D 000034E0 ZMC_GetMaxPciCards
             60   3E 00002A50 ZMC_GetOutAll
             61   3F 00002520 ZMC_GetOutput
             62   40 00001510 ZMC_GetProgress
             63   41 00002240 ZMC_GetSoftId
             64   42 00002280 ZMC_GetSoftVersion
             65   43 000015A0 ZMC_GetState
             66   44 000015B0 ZMC_GetStopPauseTaskid
             67   45 000037D0 ZMC_GetStringType
             68   46 00003510 ZMC_GetSysSpecification
             69   47 00003AE0 ZMC_GetTaskStackState
             70   48 000039D0 ZMC_GetTaskState
             71   49 000014D0 ZMC_GetTimeOut
             72   4A 00001EA0 ZMC_GetZlibGlobalDefine
             73   4B 00003F20 ZMC_GlobalArrayGet
             74   4C 00003E90 ZMC_GlobalVarGet
             75   4D 00002BC0 ZMC_JumpApp
             76   4E 00002BD0 ZMC_JumpZbios
             77   4F 00004720 ZMC_Lock
             78   50 00003120 ZMC_LowFormatNand
             79   51 00001C90 ZMC_MakeOneFileZpj
             80   52 00001E10 ZMC_MakeRealZpj
             81   53 00001E80 ZMC_MakeRealZpjMem
             83   54 00001760 ZMC_MakeZar
             82   55 00001780 ZMC_MakeZar2
             85   56 00001BB0 ZMC_MakeZarAndDown
             84   57 00001C20 ZMC_MakeZarAndDown2
             87   58 00001AD0 ZMC_MakeZarAndRamRun
             86   59 00001B40 ZMC_MakeZarAndRamRun2
             88   5A 00001E90 ZMC_MakeZlib
             89   5B 00003390 ZMC_Modbus_Get0x
             90   5C 000033F0 ZMC_Modbus_Get4x
             91   5D 00003330 ZMC_Modbus_Set0x
             92   5E 00003450 ZMC_Modbus_Set4x
             93   5F 00003E80 ZMC_ModifyLocal
             94   60 00004170 ZMC_Open
             95   61 000042C0 ZMC_OpenCom
             97   62 00004390 ZMC_OpenEth
             96   63 000043A0 ZMC_OpenEth2
             98   64 00001100 ZMC_OpenPci
             99   65 00001F60 ZMC_Pause
            100   66 00004320 ZMC_PeakCom
            101   67 000036E0 ZMC_ReadMessage
            102   68 000020E0 ZMC_RemoveAll3Files
            103   69 00003140 ZMC_ResetController
            104   6A 00001F50 ZMC_Resume
            105   6B 00003130 ZMC_ReturnDefault
            106   6C 00001F00 ZMC_RunZarFile
            107   6D 000043C0 ZMC_SearchAndOpenCom
            108   6E 00001110 ZMC_SearchAndOpenEth
            109   6F 00001340 ZMC_SearchEth
            110   70 00002340 ZMC_SetAxisEnable
            111   71 000010E0 ZMC_SetComDefaultBaud
            112   72 00003040 ZMC_SetControllerIDDate
            113   73 00002850 ZMC_SetDaOut
            114   74 000031A0 ZMC_SetMac
            115   75 000028F0 ZMC_SetOutAll
            116   76 000023E0 ZMC_SetOutput
            117   77 00001490 ZMC_SetTimeOut
            118   78 00004920 ZMC_Signal_BasicP
            119   79 00004940 ZMC_Signal_BasicV
            120   7A 00002BB0 ZMC_StartHardwareTest
            121   7B 00003900 ZMC_StepRun
            122   7C 00001F70 ZMC_Stop
            123   7D 00002BE0 ZMC_TempModBaud
            124   7E 00002B00 ZMC_TestSoftware
            125   7F 000047C0 ZMC_UnLock
            126   80 00001ED0 ZMC_UpCurZpjToMem
            127   81 000032B0 ZMC_UpFile
            128   82 000032D0 ZMC_UpFileToMem
            129   83 00003150 ZMC_UpLog
            130   84 00003160 ZMC_UpLogToMem
            131   85 00003E80 ZMC_UpZar
            132   86 00003E80 ZMC_UpZarToMem
            133   87 00003E80 ZMC_UpZarToProject
    
      Summary
    
           18000 .data
           14000 .pdata
           83000 .rdata
           13000 .reloc
            3000 .rsrc
          176000 .text
            1000 data
            1000 text
    

    修改def文件为标准def格式

    将zmotion_x64.def修改保存如下文件格式:

    LIBRARY
    
    EXPORTS
        ZMC_BreakAdd
        ZMC_BreakClear
        ZMC_BreakDel
        ZMC_CalStringHash
        ZMC_CancelOnline
        ZMC_Check3File
        ZMC_CheckFirmWare
        ZMC_CheckProgramSyntax
        ZMC_ClearLog
        ZMC_Close
        ZMC_Delete3File
        ZMC_DeleteFile
        ZMC_DirectCommand
        ZMC_DownFile
        ZMC_DownFirmWare
        ZMC_DownMemFile
        ZMC_DownMemZar
        ZMC_DownMemZarToRamAndRun
        ZMC_DownZar
        ZMC_DownZarToRamAndRun
        ZMC_EnumArray
        ZMC_EnumChildCard
        ZMC_EnumLabel
        ZMC_EnumLocal
        ZMC_EnumPara
        ZMC_EnumSub
        ZMC_EnumVar
        ZMC_Execute
        ZMC_ExecuteGetReceive
        ZMC_ExecuteGetRemainBuffSpace
        ZMC_ExecuteNoAck
        ZMC_ExecuteWaitDown
        ZMC_FastOpen
        ZMC_FindFirst3File
        ZMC_FindFirstFile
        ZMC_FindNext3File
        ZMC_FindNextFile
        ZMC_FlashReadf
        ZMC_FlashWritef
        ZMC_GetAIn
        ZMC_GetAxisFeatures
        ZMC_GetAxisStates
        ZMC_GetAxises
        ZMC_GetChipId
        ZMC_GetClientId
        ZMC_GetConnectString
        ZMC_GetConnectType
        ZMC_GetControllerIDDate
        ZMC_GetCur3File
        ZMC_GetCurIpAddr
        ZMC_GetDaOut
        ZMC_GetErrcodeDescription
        ZMC_GetError
        ZMC_GetFileState
        ZMC_GetHardId
        ZMC_GetIn
        ZMC_GetInAll
        ZMC_GetMac
        ZMC_GetMaxPciCards
        ZMC_GetOutAll
        ZMC_GetOutput
        ZMC_GetProgress
        ZMC_GetSoftId
        ZMC_GetSoftVersion
        ZMC_GetState
        ZMC_GetStopPauseTaskid
        ZMC_GetStringType
        ZMC_GetSysSpecification
        ZMC_GetTaskStackState
        ZMC_GetTaskState
        ZMC_GetTimeOut
        ZMC_GetZlibGlobalDefine
        ZMC_GlobalArrayGet
        ZMC_GlobalVarGet
        ZMC_JumpApp
        ZMC_JumpZbios
        ZMC_Lock
        ZMC_LowFormatNand
        ZMC_MakeOneFileZpj
        ZMC_MakeRealZpj
        ZMC_MakeRealZpjMem
        ZMC_MakeZar
        ZMC_MakeZar2
        ZMC_MakeZarAndDown
        ZMC_MakeZarAndDown2
        ZMC_MakeZarAndRamRun
        ZMC_MakeZarAndRamRun2
        ZMC_MakeZlib
        ZMC_Modbus_Get0x
        ZMC_Modbus_Get4x
        ZMC_Modbus_Set0x
        ZMC_Modbus_Set4x
        ZMC_ModifyLocal
        ZMC_Open
        ZMC_OpenCom
        ZMC_OpenEth
        ZMC_OpenEth2
        ZMC_OpenPci
        ZMC_Pause
        ZMC_PeakCom
        ZMC_ReadMessage
        ZMC_RemoveAll3Files
        ZMC_ResetController
        ZMC_Resume
        ZMC_ReturnDefault
        ZMC_RunZarFile
        ZMC_SearchAndOpenCom
        ZMC_SearchAndOpenEth
        ZMC_SearchEth
        ZMC_SetAxisEnable
        ZMC_SetComDefaultBaud
        ZMC_SetControllerIDDate
        ZMC_SetDaOut
        ZMC_SetMac
        ZMC_SetOutAll
        ZMC_SetOutput
        ZMC_SetTimeOut
        ZMC_Signal_BasicP
        ZMC_Signal_BasicV
        ZMC_StartHardwareTest
        ZMC_StepRun
        ZMC_Stop
        ZMC_TempModBaud
        ZMC_TestSoftware
        ZMC_UnLock
        ZMC_UpCurZpjToMem
        ZMC_UpFile
        ZMC_UpFileToMem
        ZMC_UpLog
        ZMC_UpLogToMem
        ZMC_UpZar
        ZMC_UpZarToMem
        ZMC_UpZarToProject

    生成LIB文件

    lib /def:zmotion_x64.def /machine:x64 /out:zmotion_x64.lib

    展开全文
  • 如何从DLL生成LIB文件

    千次阅读 2019-04-13 09:20:33
    设置VS2015运行环境 在开始菜单打开Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 x64 Cross Tools Command Prompt 切换到DLL所在目录 ...生成DEF文件 dumpbi...

    设置VS2015运行环境

    在开始菜单打开Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 x64 Cross Tools Command Prompt

     

    切换到DLL所在目录

    在命令窗口输入 cd /d "你的DLL目录"回车切换到对应目录。

    生成DEF文件

    dumpbin /exports zmotion_x64.dll> zmotion_x64.def

     

    生成的文件如下:

    Microsoft (R) COFF/PE Dumper Version 14.00.24210.0 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file zmotion_x64.dll File Type: DLL Section contains the following exports for zmotion.dll 00000000 characteristics 54101CA1 time date stamp Wed Sep 10 17:40:49 2014 0.00 version 1 ordinal base 136 number of functions 136 number of names ordinal hint RVA name 134 0 0000CA20 DllCanUnloadNow 135 1 0000C9C0 DllGetClassObject 136 2 0000CA60 DllRegisterServer 1 3 00003FB0 ZMC_BreakAdd 2 4 00004160 ZMC_BreakClear 3 5 00004090 ZMC_BreakDel 4 6 00001EB0 ZMC_CalStringHash 5 7 000039C0 ZMC_CancelOnline 6 8 00001F80 ZMC_Check3File 7 9 00002C50 ZMC_CheckFirmWare 8 A 000034E0 ZMC_CheckProgramSyntax 9 B 00003190 ZMC_ClearLog 10 C 00001450 ZMC_Close 11 D 000020B0 ZMC_Delete3File 12 E 00003300 ZMC_DeleteFile 13 F 000016F0 ZMC_DirectCommand 14 10 00003260 ZMC_DownFile 15 11 00002DA0 ZMC_DownFirmWare 16 12 00003280 ZMC_DownMemFile 17 13 000018A0 ZMC_DownMemZar 18 14 000019E0 ZMC_DownMemZarToRamAndRun 19 15 000017A0 ZMC_DownZar 20 16 000018D0 ZMC_DownZarToRamAndRun 21 17 00003E80 ZMC_EnumArray 22 18 00003C80 ZMC_EnumChildCard 23 19 00003E80 ZMC_EnumLabel 24 1A 00003D60 ZMC_EnumLocal 25 1B 00003E80 ZMC_EnumPara 26 1C 00003E80 ZMC_EnumSub 27 1D 00003E80 ZMC_EnumVar 28 1E 00004530 ZMC_Execute 29 1F 00001650 ZMC_ExecuteGetReceive 30 20 000016C0 ZMC_ExecuteGetRemainBuffSpace 31 21 00004430 ZMC_ExecuteNoAck 32 22 00001610 ZMC_ExecuteWaitDown 33 23 00004210 ZMC_FastOpen 34 24 00002020 ZMC_FindFirst3File 35 25 00003200 ZMC_FindFirstFile 36 26 00002050 ZMC_FindNext3File 37 27 00003230 ZMC_FindNextFile 38 28 00002160 ZMC_FlashReadf 39 29 000020F0 ZMC_FlashWritef 40 2A 000026F0 ZMC_GetAIn 41 2B 000034F0 ZMC_GetAxisFeatures 42 2C 000025C0 ZMC_GetAxisStates 43 2D 000015E0 ZMC_GetAxises 44 2E 00002270 ZMC_GetChipId 45 2F 00002230 ZMC_GetClientId 46 30 00001570 ZMC_GetConnectString 47 31 00001540 ZMC_GetConnectType 48 32 00002F40 ZMC_GetControllerIDDate 49 33 00002080 ZMC_GetCur3File 50 34 00002200 ZMC_GetCurIpAddr 51 35 000027A0 ZMC_GetDaOut 52 36 000034B0 ZMC_GetErrcodeDescription 53 37 00002250 ZMC_GetError 54 38 00003BD0 ZMC_GetFileState 55 39 00002260 ZMC_GetHardId 56 3A 00002480 ZMC_GetIn 57 3B 000029A0 ZMC_GetInAll 58 3C 000031D0 ZMC_GetMac 59 3D 000034E0 ZMC_GetMaxPciCards 60 3E 00002A50 ZMC_GetOutAll 61 3F 00002520 ZMC_GetOutput 62 40 00001510 ZMC_GetProgress 63 41 00002240 ZMC_GetSoftId 64 42 00002280 ZMC_GetSoftVersion 65 43 000015A0 ZMC_GetState 66 44 000015B0 ZMC_GetStopPauseTaskid 67 45 000037D0 ZMC_GetStringType 68 46 00003510 ZMC_GetSysSpecification 69 47 00003AE0 ZMC_GetTaskStackState 70 48 000039D0 ZMC_GetTaskState 71 49 000014D0 ZMC_GetTimeOut 72 4A 00001EA0 ZMC_GetZlibGlobalDefine 73 4B 00003F20 ZMC_GlobalArrayGet 74 4C 00003E90 ZMC_GlobalVarGet 75 4D 00002BC0 ZMC_JumpApp 76 4E 00002BD0 ZMC_JumpZbios 77 4F 00004720 ZMC_Lock 78 50 00003120 ZMC_LowFormatNand 79 51 00001C90 ZMC_MakeOneFileZpj 80 52 00001E10 ZMC_MakeRealZpj 81 53 00001E80 ZMC_MakeRealZpjMem 83 54 00001760 ZMC_MakeZar 82 55 00001780 ZMC_MakeZar2 85 56 00001BB0 ZMC_MakeZarAndDown 84 57 00001C20 ZMC_MakeZarAndDown2 87 58 00001AD0 ZMC_MakeZarAndRamRun 86 59 00001B40 ZMC_MakeZarAndRamRun2 88 5A 00001E90 ZMC_MakeZlib 89 5B 00003390 ZMC_Modbus_Get0x 90 5C 000033F0 ZMC_Modbus_Get4x 91 5D 00003330 ZMC_Modbus_Set0x 92 5E 00003450 ZMC_Modbus_Set4x 93 5F 00003E80 ZMC_ModifyLocal 94 60 00004170 ZMC_Open 95 61 000042C0 ZMC_OpenCom 97 62 00004390 ZMC_OpenEth 96 63 000043A0 ZMC_OpenEth2 98 64 00001100 ZMC_OpenPci 99 65 00001F60 ZMC_Pause 100 66 00004320 ZMC_PeakCom 101 67 000036E0 ZMC_ReadMessage 102 68 000020E0 ZMC_RemoveAll3Files 103 69 00003140 ZMC_ResetController 104 6A 00001F50 ZMC_Resume 105 6B 00003130 ZMC_ReturnDefault 106 6C 00001F00 ZMC_RunZarFile 107 6D 000043C0 ZMC_SearchAndOpenCom 108 6E 00001110 ZMC_SearchAndOpenEth 109 6F 00001340 ZMC_SearchEth 110 70 00002340 ZMC_SetAxisEnable 111 71 000010E0 ZMC_SetComDefaultBaud 112 72 00003040 ZMC_SetControllerIDDate 113 73 00002850 ZMC_SetDaOut 114 74 000031A0 ZMC_SetMac 115 75 000028F0 ZMC_SetOutAll 116 76 000023E0 ZMC_SetOutput 117 77 00001490 ZMC_SetTimeOut 118 78 00004920 ZMC_Signal_BasicP 119 79 00004940 ZMC_Signal_BasicV 120 7A 00002BB0 ZMC_StartHardwareTest 121 7B 00003900 ZMC_StepRun 122 7C 00001F70 ZMC_Stop 123 7D 00002BE0 ZMC_TempModBaud 124 7E 00002B00 ZMC_TestSoftware 125 7F 000047C0 ZMC_UnLock 126 80 00001ED0 ZMC_UpCurZpjToMem 127 81 000032B0 ZMC_UpFile 128 82 000032D0 ZMC_UpFileToMem 129 83 00003150 ZMC_UpLog 130 84 00003160 ZMC_UpLogToMem 131 85 00003E80 ZMC_UpZar 132 86 00003E80 ZMC_UpZarToMem 133 87 00003E80 ZMC_UpZarToProject Summary 18000 .data 14000 .pdata 83000 .rdata 13000 .reloc 3000 .rsrc 176000 .text 1000 data 1000 text

     

    修改def文件为标准def格式

     

    将zmotion_x64.def修改保存如下文件格式:

    LIBRARY EXPORTS ZMC_BreakAdd ZMC_BreakClear ZMC_BreakDel ZMC_CalStringHash ZMC_CancelOnline ZMC_Check3File ZMC_CheckFirmWare ZMC_CheckProgramSyntax ZMC_ClearLog ZMC_Close ZMC_Delete3File ZMC_DeleteFile ZMC_DirectCommand ZMC_DownFile ZMC_DownFirmWare ZMC_DownMemFile ZMC_DownMemZar ZMC_DownMemZarToRamAndRun ZMC_DownZar ZMC_DownZarToRamAndRun ZMC_EnumArray ZMC_EnumChildCard ZMC_EnumLabel ZMC_EnumLocal ZMC_EnumPara ZMC_EnumSub ZMC_EnumVar ZMC_Execute ZMC_ExecuteGetReceive ZMC_ExecuteGetRemainBuffSpace ZMC_ExecuteNoAck ZMC_ExecuteWaitDown ZMC_FastOpen ZMC_FindFirst3File ZMC_FindFirstFile ZMC_FindNext3File ZMC_FindNextFile ZMC_FlashReadf ZMC_FlashWritef ZMC_GetAIn ZMC_GetAxisFeatures ZMC_GetAxisStates ZMC_GetAxises ZMC_GetChipId ZMC_GetClientId ZMC_GetConnectString ZMC_GetConnectType ZMC_GetControllerIDDate ZMC_GetCur3File ZMC_GetCurIpAddr ZMC_GetDaOut ZMC_GetErrcodeDescription ZMC_GetError ZMC_GetFileState ZMC_GetHardId ZMC_GetIn ZMC_GetInAll ZMC_GetMac ZMC_GetMaxPciCards ZMC_GetOutAll ZMC_GetOutput ZMC_GetProgress ZMC_GetSoftId ZMC_GetSoftVersion ZMC_GetState ZMC_GetStopPauseTaskid ZMC_GetStringType ZMC_GetSysSpecification ZMC_GetTaskStackState ZMC_GetTaskState ZMC_GetTimeOut ZMC_GetZlibGlobalDefine ZMC_GlobalArrayGet ZMC_GlobalVarGet ZMC_JumpApp ZMC_JumpZbios ZMC_Lock ZMC_LowFormatNand ZMC_MakeOneFileZpj ZMC_MakeRealZpj ZMC_MakeRealZpjMem ZMC_MakeZar ZMC_MakeZar2 ZMC_MakeZarAndDown ZMC_MakeZarAndDown2 ZMC_MakeZarAndRamRun ZMC_MakeZarAndRamRun2 ZMC_MakeZlib ZMC_Modbus_Get0x ZMC_Modbus_Get4x ZMC_Modbus_Set0x ZMC_Modbus_Set4x ZMC_ModifyLocal ZMC_Open ZMC_OpenCom ZMC_OpenEth ZMC_OpenEth2 ZMC_OpenPci ZMC_Pause ZMC_PeakCom ZMC_ReadMessage ZMC_RemoveAll3Files ZMC_ResetController ZMC_Resume ZMC_ReturnDefault ZMC_RunZarFile ZMC_SearchAndOpenCom ZMC_SearchAndOpenEth ZMC_SearchEth ZMC_SetAxisEnable ZMC_SetComDefaultBaud ZMC_SetControllerIDDate ZMC_SetDaOut ZMC_SetMac ZMC_SetOutAll ZMC_SetOutput ZMC_SetTimeOut ZMC_Signal_BasicP ZMC_Signal_BasicV ZMC_StartHardwareTest ZMC_StepRun ZMC_Stop ZMC_TempModBaud ZMC_TestSoftware ZMC_UnLock ZMC_UpCurZpjToMem ZMC_UpFile ZMC_UpFileToMem ZMC_UpLog ZMC_UpLogToMem ZMC_UpZar ZMC_UpZarToMem ZMC_UpZarToProject

    生成LIB文件

    lib /def:zmotion_x64.def /machine:x64 /out:zmotion_x64.lib

    展开全文
  • GenerateLibFromDll Jump to: navigation, search from: http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/ Contents 1 Introduction2 Open a Comm
  • Lib静态链接库 用到的指令都被直接包含在exe文件中程序运行的时候不再需要其它的库文件静态共享代码资料个人收集整理勿做商业用途 DLL把调用的函数所在dll和函数所在位置信息链接至程序中程序运行的时候再从DLL中...
  • 使用VS从DLL生成LIB文件

    千次阅读 2016-03-09 14:21:07
    使用VS从DLL生成LIB文件
  • dll生成lib文件

    2013-12-02 18:42:15
    如何从dll文件导出对应的lib文件?    Visual C++ 开发工具提供了两个命令行工具,一个是dumpbin.exe,另一个是lib.exe。利用这两个工具即可从dll导出其对应的lib。    1、在命令行执行:  dumpbin /...
  • 在开始菜单打开Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 x64 Cross Tools Command Prompt 切换到DLL所在目录 ...生成DEF文件dumpbin /exports zmotion_x...
  • 从dll生成.lib

    2013-12-23 11:45:10
    需要工具 dumpbin.exe lib.exe 1. 查看DLL导出函数表 DUMPBIN.EXE /EXPORTS ntdll.dll 输出类似: ordinal hint RVA name 1207 4B6 0002DC81 _itow 1208 4B7 0006F989 _lfind 1209 4B8 0
  • DLL生成LIB文件

    2013-06-30 11:46:17
    如何从dll文件导出对应的lib文件?    Visual C++ 开发工具提供了两个命令行工具,一个是dumpbin.exe,另一个是lib.exe。利用这两个工具即可从dll导出其对应的lib。    1、在命令行执行:  dumpbin /...
  • 如何从DLL生成LIB文件   如何从dll文件导出对应的lib文件? Visual C++ 开发工具提供了两个命令行工具,一个是dumpbin.exe,另一个是lib.exe。利用这两个工具即可从dll导出其对应的lib。 1、在命令行执行: ...
  • 来说明怎样一个dll文件生成lib库文件。 參考OpenBlas的说明“Howto generate import library for MingW”,和MinGW的说明HOWTO Create an ImportLibrary for a DLL using MinGW,学习怎样生成lib库。当中...
  • 如何从DLL生成LIB文件? BCB可以用implib得到lib,VC稍微麻烦一些: 首先dumpbin /exports xxx.dll>xxx.def,留下xxx.def文件的输出段: ordinal hint RVA name 2 0 00001005 xxx_func1 3 1 0000100F xxx_...
  • 原文地址::http://hi.baidu.com/gaogaf/item/552a1598be7e30895914612a 相关网帖 1、Lib和Dll如何生成及联系----...2、从DLL生成LIB----http://blog.csdn.net/cheungmine/artic
  • 从DLL导出LIB文件

    千次阅读 2019-06-06 11:20:03
    Q:动态链接库DLL文件导出LIB文件 详情: 在Windows开发sqlite相关程序时,自己编译SQLite源码以生成dlllib还是比较麻烦的,所以直接下载sqlite-dll-******.zip。这个包解压出来只包含sqlite3.dll和sqlite3.def...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 488
精华内容 195
关键字:

从dll生成lib