在Visual Studio 2010中编译项目 [英] Compiling a project in Visual Studio 2010

查看:143
本文介绍了在Visual Studio 2010中编译项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Visual Studio 2010,我遇到一个名为ServiceConfigurationManager的项目的问题.更具体地说,当我尝试在名为 ServiceConfugrationManagerModule.h 的文件中执行以下代码行时:

I am facing issues with a project called ServiceConfigurationManager, using Visual Studio 2010. To be more specific, when I try to execute the following line of code in a file called ServiceConfugrationManagerModule.h:

class CServiceConfigurationManagerModule
    : public CAtlServiceModuleT <cserviceconfigurationmanagermodule,>, public CWindowImpl<cserviceconfigurationmanagermodule>
{</cserviceconfigurationmanagermodule>



我遇到了一系列错误,其中最重要的是:



I''m met with a barrage of errors, the most important of which is:

c:\work\main\actra5.x\projects\serviceconfigurationmanager\serviceconfigurationmanagermodule.h(32): error C2504: 'CAtlServiceModuleT' : base class undefined
c:\work\main\actra5.x\projects\serviceconfigurationmanager\serviceconfigurationmanagermodule.h(32): error C2143: syntax error : missing ',' before '<'




CAtlServiceModuleT atlbase.h 中定义.我并不完全确定该问题,但我怀疑由于某些设置,错误地定义了名为_ATL_NO_SERVICE的宏.在 atlbase.h 中,CAtlServiceModuleT 是在语句"#ifndef _ATL_NO_SERVICE"之后定义的. (请注意, atlbase.h 包含在my stdafx.h 中,而 atlbase.h 包含在 ServiceConfigurationModule.h 中).

该项目在Visual Studio 2005中可以轻松编译,如果我在属性页"中将平台工具集"更改为v90,它也可以完美编译.

有人对如何解决此问题有任何建议吗?不幸的是,我无法提供完整的代码,因为它是由公司内部编写的.




CAtlServiceModuleT is defined in atlbase.h. I am not entirely sure of the problem, but I suspect that somehow a macro called _ATL_NO_SERVICE is incorrectly defined due to some settings. In atlbase.h, CAtlServiceModuleT is defined following the statement ''#ifndef _ATL_NO_SERVICE''. (Note that atlbase.h is included in my stdafx.h, which in turn is included in ServiceConfigurationModule.h)

The project compiles without a hitch in Visual Studio 2005, it also compiles perfectly if I change the Platform Toolset to v90 in the Property Pages.

Does anyone have any suggestions on how to fix this problem? Unfortunately, I cannot provide the entire code since it was written internally by my company.

推荐答案

您是否知道需要重置自己的包含目录等?
Visual Studio 2010足以删除所有项目的所有全局目录,因此您必须手动将其重置.我建议您使用环境变量...第一次我很难做到,然后发现您可以使用LIB和INCLUDE环境变量.
Did you know that you need to resetup your include directories, etc?
Visual Studio 2010 is nice enough to remove all of your global directories for all of your projects and you have to reset them up manually. I suggest that you use environment variables... I did it the hard way the first time and then found out that you can use LIB and INCLUDE environment variables.


有一个上下文菜单项Studio的源视图中的转到定义".
在打开的_ATL_NO_SERVICE解决方案中使用它:)
There is a context menu item "Go To Definition" in a source view of a Studio.
Use it in your opened solution for _ATL_NO_SERVICE :)


原始VS2008/VS2005 stdafx.h中的源代码可以很好地编译,但不会在VS2010上编译,并出现相同的错误.
Original VS2008/VS2005 Source in stdafx.h compiles just fine but will not compile on VS2010 with same error.
error C2504: 'CAtlServiceModuleT' : base class undefined





#include <afx.h>
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
    #include <afxdtctl.h>       // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
    #include <afxcmn.h>         // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#undef _AFX
#undef _ATL_NO_SERVICE

#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>



stdafx.h中更新的VS2010 Source可以正常编译.技巧是交换AFX和ATL顺序并添加#undef _WINDOWS_,然后再包括MFC标头为我完成技巧.



Updated VS2010 Source in stdafx.h compiles just fine. Trick is to swap AFX and ATL order and add #undef _WINDOWS_ before including the MFC headers did the trick for me.

#undef _ATL_NO_SERVICE
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>
#undef _WINDOWS_

#include <afx.h>
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
    #include <afxdtctl.h>       // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
    #include <afxcmn.h>         // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#undef _AFX


这篇关于在Visual Studio 2010中编译项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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