学习ObjectArx编写时候遇到的各种问题汇总
学习objectarx遇到的种种问题
1.按照2007帮助中的每一步进行之后,在编译的时候出现
acutPrintf (_T("\nHello World!"));
出现这样的错误: '_T': identifier not found
在此页得到回答
http://www.objectarx.net/bbs/viewthread.php?tid=2168&extra=page%3D6
加这个头文件“TCHAR.h”
#include "TCHAR.h"
2. rxapi.lib(libinit.obj) : warning LNK4099: PDB 'rxapi.pdb' was not found with 'E:\ObjectARX2007\lib\rxapi.lib' or at 'g:\learnarx\hello\qj\debug\rxapi.pdb'; linking object as if no debug info
qj.exp : warning LNK4070: /OUT:qj.dll directive in .EXP differs from output filename 'G:\learnarx\hello\qj\Debug\qj.arx'; ignoring directive
查到此页
http://topic.csdn.net/u/20080412/14/8b3b0157-d3c1-4313-bc1d-6ca89840b240.html
和此页
http://www.mjtd.com/bbs/dispbbs.asp?boardID=14&ID=57411&page=1
说,按道理就是这样的,没有问题
3. 现在在加文字 的时候,编译出现了这个错误
错误1error C2664: 'AcDbText::AcDbText(const AcGePoint3d &,const ACHAR *,AcDbObjectId,double,double)' : cannot convert parameter 2 from 'const char *' to 'const ACHAR *'e:\c\objectarx\temp\temp\qjcreateent.cpp87
后来查相关的objectARX的帮助,发现是这样的问题
AcDbText(
const AcGePoint3d& position,
const ACHAR* text,
AcDbObjectId style = AcDbObjectId::kNull,
double height = 0,
double rotation = 0);
而张帆书上的表达是 char* text
所以我修改了一下,不知道有没有用
没有用,结果要把字符串改成 (_T(“ddd”)); 才行
4. 错误
错误1fatal error LNK1104: 无法打开文件“rxapi.lib”temp
发现出现了这个错误
那就是lib没有引入了,要修改linker
rxapi.lib acdb17.lib acge17.lib acad.lib acedapi.lib 根据帮助文档的说法,要假如这几个lib
5. 错误
继续运行,发现有如下问题
错误1error C2653: 'CCreateEnt' : is not a class or namespace namee:\c\objectarx\temp\temp\acrxentrypoint.cpp69
错误2error C3861: 'CreateLine': identifier not founde:\c\objectarx\temp\temp\acrxentrypoint.cpp69
错误3error C2653: 'CCreateEnt' : is not a class or namespace namee:\c\objectarx\temp\temp\qjcreateent.cpp12
这个说明刚才的打错了—qjCreateent而非 CcreateEnt(这个是张帆的例题的)
6. 错误
可以看到出现如下的错误
错误1fatal error C1083: Cannot open include file: 'arxHeaders.h': No such file or directorye:\c\objectarx\temp\temp\stdafx.h95
那是因为没有加入inc路径
可以右键点击项目后,选到这个inc的选项后加入
7. 今天遇到的新的错误是
错误1error C2065: 'helloWorld' : undeclared identifierg:\work new pc\编程\c++\arx2011\arx2011\arx2011\helloworld.cpp19
错误2error C2365: 'helloWorld' : redefinition; previous definition was 'formerly unknown identifier'g:\work new pc\编程\c++\arx2011\arx2011\arx2011\helloworld.cpp34
错误3error C4430: missing type specifier - int assumed. Note: C++ does not support default-intg:\work new pc\编程\c++\arx2011\arx2011\arx2011\helloworld.cpp41
唉,总是好多错误
前两个错误是发现,忘记写这个代码了
void helloWorld();
然后,又出现了这个错误
错误1error C2664: 'AcEdCommandStack::addCommand' : cannot convert parameter 5 from 'void' to 'AcRxFunctionPtr'g:\work new pc\编程\c++\arx2011\arx2011\arx2011\helloworld.cpp20
检查了一下,发现
// register a command with the AutoCAD command mechanism
acedRegCmds->addCommand(_T("HELLOWORLD_COMMANDS"),
_T("Hello"),
_T("Bonjour"),
ACRX_CMD_TRANSPARENT,
helloWorld());
这个最后一个的括号,要去掉,太多错误了,郁闷
ap appload
acrxGetApiVersion not found in R:\arx2011.arx
Make sure the app links with rxapi.lib and export the symbol.AcRxDynamicLinker
failed to load 'R:\arx2011.arx'
D:\Program Files\AutoCAD 2007\acad.exeUnable to load arx2011.arx file.
在CAD中加载后,出现这个问题,是没有写DEF吧
所以,最后的代码,就是这样了
#include "stdafx.h"#include <aced.h>#include <rxregsvc.h> #include <TCHAR.h>void initApp();void unloadApp(); void helloWorld();void initApp(){ // register a command with the AutoCAD command mechanismacedRegCmds->addCommand(_T("HELLOWORLD_COMMANDS"),_T("Hello"),_T("Bonjour"),ACRX_CMD_TRANSPARENT,helloWorld);}void unloadApp(){ acedRegCmds->removeGroup(_T("HELLOWORLD_COMMANDS"));}void helloWorld(){ acutPrintf(_T("\nHello World!"));}extern "C" AcRx::AppRetCodeacrxEntryPoint(AcRx::AppMsgCode msg, void* pkt){switch (msg){case AcRx::kInitAppMsg:acrxDynamicLinker->unlockApplication(pkt);acrxRegisterAppMDIAware(pkt);initApp();break;case AcRx::kUnloadAppMsg:unloadApp();break;default:break;}return AcRx::kRetOK;}EXPORTSacrxEntryPoint PRIVATEacrxGetApiVersion PRIVATE