使用DLL时如何减少QT程序的启动时间

使用DLL时如何减少QT程序的启动时间

本文介绍了使用DLL时如何减少QT程序的启动时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序在启动过程中依赖于几个DLL,包括QT本身的QtCore4.dll和QtGui4.dll以及National Instruments的ni488.dll。当我尝试使用cbw32.dll中的任何功能时(在UniversalLibrary中的),我的程序突然需要5秒钟以上的时间才能启动,而以前它是瞬间启动的。我有什么办法可以减少启动时间?因此,在这段时间内发生了什么事情,OS是在主动链接功能,还是只是试图找到DLL?有什么方法可以减小DLL的大小,以便仅包含与我的项目相关的内容?还是将这些信息包含在可执行文件本身中(换句话说就是静态链接)?

My program relies on several DLLs during startup, including QtCore4.dll and QtGui4.dll from QT itself and ni488.dll from National Instruments. When I try using any of the functions in cbw32.dll (a 5 MB file found in the UniversalLibrary at http://www.mccdaq.com/software.aspx), my program suddenly takes 5+ seconds to start up, whereas previously it did so instantaneously. Is there anything I can do to reduce the time it takes to start up? For that matter, what is happening during that time, is the OS actively linking the functions, or merely trying to find the DLL? Is there any way to reduce the size of the DLL so as to include only the stuff that's relevant to my project? Or include that information in the executable itself (static linking, in other words)?

编辑:并行加载DLL确实是一个不错的建议(这是我'将继续使用),但并不能解决我认为是这里的核心问题。拥有5 MB的DLL需要5秒钟的加载时间,这似乎过多了,对我而言,这表明存在更深的问题。我的期望值不在这里,这些加载时间是正常的吗?还是真的有什么问题(如果是,那么我应该调查什么)?

loading the DLL in parallel is indeed a nice suggestion (and a technique that I'll use going forward), but doesn't get at what I perceive to be the core problem here. Having a 5 MB DLL take 5 seconds to load seems excessive, and to me indicates that there's a deeper problem. Are my expectations off here, and these load times are normal? Or is there really something wrong (and if so, what should I look into)?

推荐答案

为什么不动态加载该dll?

Why not load this dll dynamically in a parallel thread on start-up then?

HINSTANCE hGetProcIDDLL = LoadLibrary(L"library.dll");

是一个很好的例子。

这篇关于使用DLL时如何减少QT程序的启动时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 00:42