• 在Windows平台下Qt的exe报错问题排查步骤


    在Windows平台下Qt的exe报错问题排查步骤

     工具介绍:

    1. Dependency Worker

      Dependency Worker是一个免费的用具用来扫描任何的32bit 或者64bit 的Windows模块(可以是exe,dll, sys,etc.) ,并建立hierarchical tree 各种模块的依赖图。 对于每个发现的模块, 该软件列出了所有被这个模块使用的函数, 这些函数实际是被其他模块调用。另一种视图展示最小的依赖文件的集合。 并伴随着相似的信息。

      Dependency Worker 同样是非常有用的toubleshooting system errors (故障排除系统错误) ,这些错误与loading 和executing modules,即这些模块的加载和执行依赖。 

      Dependency Worker 检测许多常见的应用问题,如丢失modules, 无效的modules, import/export mismatches, circular dependency errors, 模块类型的错误匹配, 以及模块初始化误差等等。

      Dependency Worker 可以执行在Wind95, 98, ME, NT,  2000,XP, 2003, Vista, 7, and 8; 能够处理检测在32bit 或者64bit的的windows module, 包括 为Window CE 设计的模块。 

      Dependency Worker 可以以图形应用显示,或者是控制台应用。两种使用方式。 能够处理模块依赖的所有类型问题,报错implicit, explicit (dynamic/ runtime), forwarded, delay-loaded, and injected. 还可以提供详细的帮助信息。

      

    2. Process Explorer v16.22

      Process Explorer  ,可以用来检擦哪一个程序打开了特定了文件或者目录。Process Explore 可以显示出处理的信息,以及打开或者加载的dll。

      process Explorer 的显示由两个子窗口组成。 上面窗口展示当前活动的进程列表, 包括账户名称, 则在下面的窗口中展示的信息依赖于当前的Process Explorer选中的条目。 当Process Explorer 是handle mode , 则将会处理选中的process。如果Process Explorer 是在Dll 模式,将会看到dll 的捏村匹配的文件。同样Process Explorer 江湖快速的展示特定的打开的句柄,或者加载的dll 。

      Process Explorer 最重要的能力是来最终Dll 的版本号问题,以及 handle leak句柄的泄露, 并提供给窥视Windows 和应用的工作。

    3. windeployqt

      Qt 自带的发布以及依赖exe 的qt 库的工具。 

      Qt 程序开发完成后, 需要在没有Qt 开发环境的系统上部署exe,对exe依赖的qt 各种模块自动添加到exe目录位置。进行快速部署。

    (1)Windows部署工具功能

      Windows部署工具旨在自动执行创建可部署文件夹的过程,该文件夹包含从该文件夹运行应用程序所需的与Qt相关的依赖关系(库,QML导入,插件和翻译)。 它为Windows运行时创建沙箱或为Windows桌面应用程序创建安装树,可以轻松将其捆绑到安装包中。

      该工具可以在QTDIR / bin / windeployqt中找到。 它以.exe文件或包含.exe文件的目录作为参数,并扫描可执行文件的依赖关系。 如果使用–qmldir参数传递目录,则windeployqt将使用qmlimportscanner工具扫描目录中的QML文件以获取QML导入依赖关系。 然后将识别的依赖关系复制到可执行文件的目录中。 Qt5Core.dll中的硬编码本地路径进一步被相关的替换。
       如果应用程序可能需要额外的第三方库(例如数据库库),windeployqt不会考虑这些库

      

     使用方法 :

    1. 使用windeployqt最简单的方法是添加Qt的bin目录

      安装(例如<QT_DIR bin>)到PATH变量,然后运行:

      windeployqt <path-to-app-binary>
    如果ICU,ANGLE等不在bin目录中,则需要在PATH中变量。
     如果您的应用程序使用Qt Quick,请运行:
    windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>

    2. 直接在控制台Win+R, cmd 控制台命令行:

    执行以下: cd 导航到 <QTDIR>in所在目录,这样,就可以直接在Window 控制台命令行直接使用 windepolyat 了。

       最简单的调用方法:

      windeployqt  exe所在目录

    Usage: windeployqt [options] [files]
    
    Options:
      -?, -h, --help            Displays this help.
      -v, --version             Displays version information.
      --dir <directory>         Use directory instead of binary directory.
      --libdir <path>           Copy libraries to path.
      --plugindir <path>        Copy plugins to path.
      --debug                   Assume debug binaries.
      --release                 Assume release binaries.
      --pdb                     Deploy .pdb files (MSVC).
      --force                   Force updating files.
      --dry-run                 Simulation mode. Behave normally, but do not
                                copy/update any files.
      --no-patchqt              Do not patch the Qt5Core library.
      --no-plugins              Skip plugin deployment.
      --no-libraries            Skip library deployment.
      --qmldir <directory>      Scan for QML-imports starting from directory.
      --no-quick-import         Skip deployment of Qt Quick imports.
      --no-translations         Skip deployment of translations.
      --no-system-d3d-compiler  Skip deployment of the system D3D compiler.
      --compiler-runtime        Deploy compiler runtime (Desktop only).
      --no-compiler-runtime     Do not deploy compiler runtime (Desktop only).
      --webkit2                 Deployment of WebKit2 (web process).
      --no-webkit2              Skip deployment of WebKit2.
      --json                    Print to stdout in JSON format.
      --angle                   Force deployment of ANGLE.
      --no-angle                Disable deployment of ANGLE.
      --no-opengl-sw            Do not deploy the software rasterizer library.
      --list <option>           Print only the names of the files copied.
                                Available options:
                                 source:   absolute path of the source files
                                 target:   absolute path of the target files
                                 relative: paths of the target files, relative
                                           to the target directory
                                 mapping:  outputs the source and the relative
                                           target, suitable for use within an
                                           Appx mapping file
      --verbose <level>         Verbose level.
      
    Arguments:
      [files]                   Binaries or directory containing the binary.

      windeployqt -h 输出help文件信息,如下图:

      

      windeployqt.exe d:filexxxapp.exe

      

      然后就可以对exe直接“打包”程序了:

      

      注意:

    1. 如果对第三方的类库使用了,就要将相应的dll自己拷贝到相应的目录位置;

      如: 

      glut32.dll, glew32.dll等类库

      

     2. 对于qt 的部分类库dll,往往也不能自动添加,则可以对<QTDIR>/bin 目录下的qtdll 根据项目的使用情况,自己添加相应的dll,

      如下图:

      则Qt5Opengld.dll, Qt5Xmld.dll 则需要自己添加到exe 目录中。

      

    3. 或者根据在VS输出的exe加载的历史纪录中逐个比对,查看是否在exe 的目录中。

      来判断差异:

      

      

    endl;

  • 相关阅读:
    简历的快速复制
    使用stringstream对象简化类型转换
    猴子吃桃
    new和delete运算符
    绘制正余弦曲线
    计算学生的平均成绩
    判断是否为回文字符串
    统计各种字符个数
    验证用户名
    回溯法(挑战编程)
  • 原文地址:https://www.cnblogs.com/icmzn/p/10293904.html
Copyright © 2020-2023  润新知