您的位置:首页 > 其它

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

2013-07-24 10:29 423 查看
总结了编译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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐