• gendef和pexports


    gendef 和 pexports

    gendef和pexports都可以从DLL和对应头文件中提取信息,创建相应的.def文件以列出每个DLL中可用的符号。然后,你可以用dlltool(binutils)通过.def文件来生成对应的导入库(import library),这样就可以解决DLL开发商未提供所需开发平台导入库的问题。

    安装

    gendef和pexports可以通过MinGW(32-bit)安装管理器安装:
    gendef
    pexports
    也可以通过上图中给出的链接直接下载。
    由于它们只能通过“All Packages”分类才能选中下载,其下的子项中都没有列出,非常隐蔽。
    在MSYS2/MinGW-w64环境下查询和安装gendef的命令:

    pacman -Fy
    pacman -F gendef.exe
    pacman -S --needed mingw-w64-x86_64-tools-git
    
    • 1
    • 2
    • 3

    软件描述

    在这里插入图片描述

    gendef can extract information from DLLs to create corresponding .def files that list the symbols available in each DLL. .def files can then be used by dlltool (mingw32-binutils) to generate import libraries. gendef is similar to pexports, but the two tools differ in how each determines the “decoration” (or calling convention) appropriate for each symbol, since that information is not always available directly from the DLL’s symbol table. gendef locates the symbol’s code in the DLL, and uses a disassembler to determine that information. pexports can use a C pre-processor to extract the information, provided you have the appropriate header files. Neither method is foolproof, so both tools are provided.
    gendef was written by the MinGW64 team. It can extract symbols from 32bit or 64bit EXEs or DLLs. It can automatically detect stdcall, fastcall, and cdecl calling conventions and generate the correctly decorated function names, without requiring the header files or a C pre-processor.

    Description

    pexports can extract information from DLLs to create corresponding .def files that list the symbols available in each DLL. .def files can then be used by dlltool (mingw32-binutils) to generate import libraries. pexports is similar to gendef, but the two tools differ in how each determines the “decoration” (or calling convention) appropriate for each symbol, since that information is not always available directly from the DLL’s symbol table. pexports can use a C pre-processor to extract the information, provided you have the appropriate header files. gendef locates the symbol’s code in the DLL, and uses a disassembler to determine that information. Neither method is foolproof, so both tools are provided.
    Note that in order for pexports to detect the calling convention, you must specify on the command line the headers to parse. If the symbols are not declared in those headers, then the proper decorations cannot be computed. Originally written by Anders Norlander, it now supports both 32bit and 64bit DLLs and EXEs thanks to Tor Lillqvist.

    例子

    gendef steam_api64.dll
    dlltool -D steam_api64.dll -d steam_api64.def -l libsteam_api64.a
    
    • 1
    • 2

    第一步生成steam_api64.def。
    第二步如果缺少"-d steam_api64.def",在链接 libsteam_api64.a 时就会出现“undefined reference to ‘xxx’”之类的错误。

    参考

    Sourceforge: gendef
    Sourceforge: Generating an import library for a DLL
    Sourceforge: MSYS2 gendef is not found
    Github: gendef
    Github: pexports
    GNU binutils

  • 相关阅读:
    【黄啊码】composer运行php相关问题解决方式
    ios不越狱虚拟定位教程:如何在iOS设备上实现无需越狱的虚拟定位
    Maven 私服Nexus的搭建教程windows(搭配android maven插件使用)
    发挥数字化平台优势,电子元器件采购商城系统助力企业改变固有低效流程
    软考软件设计师-计算机组成与体系结构(上
    诠释韧性增长,知乎Q3财报里的社区优势和商业化价值
    C++:添加头文件时出错C3646和C4430
    射频功率放大器的指标有哪些内容
    解析 Python requests 库 POST 请求中的参数顺序问题
    redis的原理和源码-发布订阅
  • 原文地址:https://blog.csdn.net/feiyunw/article/details/127813780