在 Visual Studio 2008 中构建应用程序发布时出现问题 - C++

发布于 2024-10-08 01:24:24 字数 646 浏览 0 评论 0原文

我在 Visual Studio 2008 中将应用程序构建为发布版时遇到了一些问题。它构建得很好,没有任何错误或警告为调试版。该应用程序主要是 Win32,其中混杂着一些 MFC 和 ATL。解决方案中的大多数项目都会生成 LIB 和 DLL。

这是我收到的错误之一:

致命错误 C1189:#error:使用 /MD[d](CRT dll 版本)构建 MFC 应用程序需要 MFC 共享 dll 版本。请#define _AFXDLL 或不要使用/MD[d]

我的应用程序是一个多线程DLL,因此需要保留/MD。唯一的 Windows 包括这些:

#include "stdafx.h"
#include "afx.h"
#include "WMIQuery.h"
#include "SerialPort.h"

另一个错误是这样的:

致命错误 C1083:无法打开包含文件:'WMIQuery.h':没有这样的文件或目录

这对我来说确实没有意义,因为环境没有问题找到为调试构建的此文件。

有谁知道如何解决这个问题?如果需要任何其他信息,请直接说出来,我会发布。谢谢。

I'm having a little trouble building my application as Release in Visual Studio 2008. It builds fine without any errors or warning as Debug. The application is primarily Win32 with a little MFC and ATL mixed in here and there. Most of the projects in the solution generate a LIB and DLL.

This is one of the errors I am getting:

fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

My application is a multithreaded DLL, so the /MD needs to stay. The only Windows includes are these:

#include "stdafx.h"
#include "afx.h"
#include "WMIQuery.h"
#include "SerialPort.h"

The other error is this:

fatal error C1083: Cannot open include file: 'WMIQuery.h': No such file or directory

This one really doesn't make sense to me because, the environment has no problem finding this file building for Debug.

Does anyone know how to fix this? If any additional information is needed, just say so, and I'll post. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

樱娆 2024-10-15 01:24:24

您为在调试配置中构建而所做的项目属性更改也不会自动应用于发布配置。请注意对话框左上角的“配置”组合。更改的属性值以粗体显示。

如果您不记得所做的更改,请在文本编辑器(如 Notepad.exe)中打开 .vcproj 文件。与默认值相比发生更改的设置列在“调试|Win32 配置”部分中。

The project property changes you've made to get it to build in the Debug configuration are not automatically applied to the Release configuration as well. Note the "Configuration" combo in the upper left corner of the dialog. Altered property values are shown in bold type.

If you cannot remember what changes you've made then open the .vcproj file in a text editor like Notepad.exe. The settings that were changed from their default value are listed in the Debug|Win32 configuration section.

雨落□心尘 2024-10-15 01:24:24

第一个错误很可能是您的项目设置不匹配。由于您需要 /MD,请在“常规”标题下检查您的项目配置属性以进行发布。应该有一个项目“MFC的使用”。应将其设置为“在共享 DLL 中使用 MFC”。

第二个错误可能是由于两个配置之间的包含路径不匹配造成的。

The first error is most likely a mismatch in your project settings. Since you require /MD, check your project configuration properties for release, under the 'General' heading. There should be an item "Use of MFC". This should be set to "Use MFC in a Shared DLL".

The second error is probably due to a mismatch in include paths between the two configurations.

左岸枫 2024-10-15 01:24:24

仔细检查您的环境变量。我相信它使用单独的值进行调试和发布。

Double-check your environment variables. I believe it uses separate values for debugging and releasing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文