当/ MT和/ MD都需要做些什么? [英] What to do when /MT and /MD both required?

查看:232
本文介绍了当/ MT和/ MD都需要做些什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一种的后续<一个href=\"http://stackoverflow.com/questions/15105785/force-order-of-linking-libraries-in-qt-creator\">this问题我昨天公布。我的问题关于其运行时的C ++库来链接。我使用Qt作为我的IDE框架和QtCreator。根据Digia公司文档<一href=\"http://qt-project.org/faq/answer/why_does_a_statically_built_qt_use_the_dynamic_visual_studio_runtime_librar\"相对=nofollow>这里,Qt的已经知道当与 / MT 标记(这使得你的应用程序运行针对静态运行时库)。不过,我还使用第三方驱动程序在此应用程序,并在该应用程序的文档明确表示,它不会建立,除非你对静态运行时库链接。果然,它编译罚款与 / MT 标记,但给了我大约40链接错误,当我删除该设置。 (到目前为止我只包括驾驶员的静态库一个头文件)

This is a sort of follow-up to this question I posted yesterday. My problem regards which runtime C++ libraries to link against. I am using Qt as a framework and QtCreator for my IDE. According to the digia docs here, Qt has been known to have memory problems when built with the /MT flag (which makes your app run against the static runtime libraries). However, I'm also using a 3rd party driver in this app, and the docs on that app specifically say that it won't build unless you link against the static runtime libraries. Sure enough, it compiles fine with the /MT flag, but gives me about 40 linker errors when I remove that setting. (and so far I'm only including one header file from the driver's static library)

所以我的问题是:什么是在这里做了正确的事情吗?有没有办法迫使驾驶员期望的动态运行时库?或者我应该生活在Qt的内存管理的问题?或者是有办法有对动态的和司机(以及它需要加速的部分)的链接对静态的Qt的链接? (和记住,我在QtCreator这样做,不是工作室)

So my question is: what's the correct thing to do here? Is there a way to force the driver to expect the dynamic runtime library? Or should I live with Qt's memory management problem? Or is there a way to have Qt link against the dynamic ones and the driver (and the parts of Boost that it requires) link against the static ones? (and keep in mind that I'm doing this in QtCreator, not studio)

推荐答案

两个 / MT / MD 是链接器选项。如果你正在构建多个模块,你可以有多种选择。

Both /MT and /MD are linker options. If you're building multiple modules, you can have multiple options.

在此情况下,使用 / MD 为Qt和你自己的code。裹司机在自己的DLL,与非CRT相关的API,并连接一个DLL与 / MT 。使用COM可能是一种选择。这当然不是CRT依赖,但它可能是矫枉过正。

In this case, use /MD for Qt and your own code. Wrap the driver in its own DLL, with a non-CRT-dependent API, and link that DLL with /MT. Using COM might be an option. That's certainly not CRT dependent, but it may be overkill.

这篇关于当/ MT和/ MD都需要做些什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆