COM技术内幕

 总结了编译Com技术内幕的最后例子的编译问题. 收藏

在编译<Com技术内幕>>的最后一个例子程序时碰到的问题:

编译:Canvas
1: midl : command line error MIDL1001 : cannot open input file canvas_i.idl
  
   通过菜单: Tool->Options->Directories 把TANGRAM目录中的IDL文件夹加入到:Include files.

2: fatal error C1083: Cannot open include file: 'CUnknown.h': No such file or directory
  
   通过菜单: Tool->Options->Directories 把TANGRAM目录中的Common文件夹加入到:Include files.

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

   通过菜单: Tool->Options->Directories 把TANGRAM目录中的Share文件夹加入到:Include files.

4: fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

   在Canvas.cpp文件的最前面,也就是#include <windows>前加上 #include <afx.h>

   在看到这个错误的时候,可以看到在这行的前面是编译哪个文件出现的问题,在这里看到的是Canvas.cpp,
   如果在编译别的程序的时候,也出现这样的问题,按照同样的方法处理.

5: error C2065: 'IsValidAddress' : undeclared identifier
   
   把在Canvas.cpp中 #include "util.h"改为
  
    #include <atlbase.h>
    #include "..\\common\\util.h"

6: error C2440: '=' : cannot convert from 'void *' to 'struct HINSTANCE__ *'
     把CFactory::s_hModule = hModule ;改为:
     CFactory::s_hModule = (HINSTANCE)hModule ;

编译成功

2. 编译:GdiWrld
   按照上面操作后,还出现如下错误:
   1). fatal error C1083: Cannot open include file: 'tantype.h': No such file or directory
   2). 'E:\OPC\TANGRAM\share\Event_I.c': No such file or directory
 
   看了一下Event_I.c这个文件是由IDL目录下的Event.IDL通过midl产生的,而Event.IDL在编译Model时才编译,因此我们先

编译Model

3. 编译Model
    出现的新的错误为:
   1. error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class

std::list<struct tagCONNECTDATA,class std::allocator<struct tagCONNECTDATA> >::const_iterator' (or there is

no acceptable conversion)

   通过双击该错误,定位错误,然后把前面一行CConnectionPointList::iterator p ; 改为:
    CConnectDataList::const_iterator p;

   也就是把iterator改为const_iterator

   编译通过

继续编译GdiWrld.

   出现的错误为:
     error C2440: 'initializing' : cannot convert from 'void *' to 'struct HPEN__ *'
     error C2440: 'initializing' : cannot convert from 'void *' to 'struct HBRUSH__ *'
    进行强制转换一下
    编译通过.
4. 编译GlWrld
   出现的新问题是:
    error C2065: 'assert' : undeclared identifier
    加入头文件:
      #include <assert.h>

  出现的其他错误记得把"util.h"改为:"..\\common\\util.h"即可。
5. 编译Tangram
   没出现什么新问题,顺利成功。


6. 运行的时候可能会提示没有注册类别
     把编译生成的dll注册一下,同时把Tangram注册为服务:
     Tangram.exe regserver

  


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lllxy/archive/2009/06/17/4277642.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值