stand on the shoulders of giants

ATL开发COM组件及Fatal Error C1853

I'm a new guy to COM develop.

  • 历史:

ATL,Active Template Library活动模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。通过活动模板库,可以建立COM组件,然后通过ASP页面中的脚本对COM对象进行调用。

开发COM组建的历史

  使用COM SDK--> 使用MFC --> ATL

COM SDK,最基本也是最灵活的方式, 开发方式的难度和工作量都很大.

MFC在提高了自动化程度,缩短了开发时间, 但是MFC对COM的支持是不够完善和彻底的,例如对COM接口定义的IDL语言,并没有任何支持。MFC对COM的支持是以其全局目标(Windows编程)为出发点的,对COM的支持不能很好满足。开发出的Activex Control,是Fat Code, 依赖于MFC的运行时刻库。

ATL是针对COM开发的一套库。ATL开发出来的COM应用的代码简练高效,即所谓的“Slim Code”。

 

  • 遇到的问题Fatal Error C1853

直接按照fangyukuang的方法去include在AtlLibrary工程中的 _i.h .i.c是没有问题的。

如果把这两个文件拷贝到client端,编译产生错误 

Error 1 error C1853: 'Debug\ConsoleApp.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa) 

Google一番知道错误的原因,
The compiler attempts to use a precompiled header generated by a C++ compiler on a C source file. This can happen when "Per-File Use of Precompiled Headers" is used with both C and C++ source code in a project.
因为client工程有C和C++文件,如果“Per-File Use of Precompiled Headers",那么.i.c文件就尝试使用precompiled header: ConsoleApp.pch(是由C++ compiler编译的)

解决方法:在.i.c属性页面,c/C++ ---> Precompiled header ---> Not using precompiled headers

posted @ 2010-11-24 14:49  DylanWind  阅读(784)  评论(0编辑  收藏  举报