简体   繁体   English

当我不是从IDE中启动QT4编写的程序时,如何执行它?

[英]How can I make the program I wrote with QT4 execute when I launch it not from IDE?

When I run the program from IDE (VS2008) it works perfectly. 当我从IDE(VS2008)运行程序时,它可以完美运行。 When I want to launch it from Windows Commander it doesn't work because it needs DLL that wasn't found. 当我想从Windows Commander启动它时,它无法工作,因为它需要找不到的DLL。 Used both debug and release builds. 使用了调试和发行版本。

Make sure the Qt DLL's are in your PATH . 确保Qt DLL在您的PATH Two simple solutions are: 两个简单的解决方案是:

  • Copy Qt's DLL's to your EXE 's directory. 将Qt的DLL复制到EXE的目录中。
  • Copy Qt's DLL's to %WINDOWS%\\System32 (eg C:\\WINDOWS\\System32 ) ( possibly unsafe, especially if you install another versions of Qt system-wide . Also, requires administrative privilages). 将Qt的DLL复制到%WINDOWS%\\System32 (例如C:\\WINDOWS\\System32 )( 可能不安全,尤其是在系统范围内安装其他版本的Qt时 。此外,还需要管理特权)。

You should make sure that the DLLs needed by the executable (probably QT Dlls) are in the PATH or in the same directory as the executable. 您应确保可执行文件(可能是QT Dll)所需的DLL位于PATH或与可执行文件相同的目录中。 You can find which dlls are needed by using depends.exe 您可以使用depends.exe查找所需的dll。

另一个解决方案是在VS工具->选项->项目和解决方案-> VC ++目录中放置qt bin子目录的路径。

You could link it statically with all the libraries it needs. 您可以将其与所需的所有库静态链接。 Saves messing around with DLLs and stuff. 节省了DLL和其他内容的混乱。 On the down side, you can't update DLLs on your installed PCs to get updated/improved/fixed functionality, and will need to rebuild and redeploy. 不利的一面是,您无法在已安装的PC上更新DLL以获取更新/改进/修复的功能,并且需要重建和重新部署。

So whether or not this is viable depends on what your installation targets are - a few PCs controlled by you, or every man+dog who decides to download your program? 那么,这是否可行取决于您的安装目标是-您控制的几台PC,还是决定下载程序的每个人+狗?

Statically compiling in a library bug (security hole for example) and shipping that to your clients would be very poor form. 静态地编译库错误(例如,安全漏洞)并将其传送给客户将是非常糟糕的形式。 Doing the same on a secure corporate intranet may make it worth doing just so that you know that each install is running exactly the same. 在安全的公司Intranet上执行相同的操作可能值得这样做,以便使您知道每次安装都运行完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM