紧急呼叫:为什么会这样,那样不太麻烦!!
本帖最后由 作者 于 2005-3-10 12:06:33 编辑 <br /><br /> 老是在.def那边出错 是不是环境设置问题呀--------------------Configuration: Entities - Win32 Debug--------------------<BR>Linking...<BR>Entities.def : error LNK2001: unresolved external symbol acrxGetApiVersion<BR>Debug/Entities.lib : fatal error LNK1120: 1 unresolved externals<BR>LINK : fatal error LNK1141: failure during build of exports file<BR>Error executing link.exe.
Entities.dll - 3 error(s), 0 warning(s)
是不是所有的 ARX编程都要进行这样类似的设置
(1) 选择菜单命令【Project】→【Settings…】,弹出“Project Settings”对话框。
(2) 在“Project Settings”对话框中选择“Setting For:”下拉列表的“All Configurations”项。<BR> (3) 在“Project Settings”对话框中选择“C/C++”选项卡。<BR> (4) 在“Category:”下拉列表中选择“Code Generation”项。然后选中“Use run-time library”下拉列表中的“Multithreaded DLL”选项(如图38-6所示)。再在“Category:”下拉列表框中选择“Preprocessor”项,然后在“Preprocessor definitions:”编辑框中内容的后面添加“ACRXAPP,RADPACK”,表示需要预链接的库(如图38-7所示)。<BR> (5) 在“Project Settings”对话框中选择“Link”选项卡。<BR> (6) 在“Category:”下拉列表中选择“General”项,然后在“Output file name:”编辑框中键入应用程序名“.\HelloARX.arx”(图38-8);在“Object/library modules:”编辑框中添加“acutil15.lib acrx15.lib acdb15.lib acedapi.lib rxapi.lib acad.lib acge15.lib”;在“Category:”下拉列表框中选择“Output”项,然后在“Base address:”编辑框中键入“0x1c000000”(图38-9)。<BR> ???????????????
不明白你的意思
不需要设置什么呀! 那为什么很多初级教程都要做这一步设置
tool。。。。
project。。。。
如果没有ARX Wizard, 环境设置就是要做的
这个export function是你在Link中添加的那么一大堆东西中间那个rxapi.lib负责的.那些初级教程所做的是在ObjectARX还没有Wizard时候的事, 现在应该是2000及以上都有Wizard可用, 所以什么都不用设置, Wizard会自动生成.
如果你有ObjectARX Wizard就用(ARX的文件夹里有一个utils文件夹, wizard的安装文件在里头), 如果没有..好象就只有每次重新设置过了..
其实最需要的设置只有Link下面那些library module和output filename, 用一个notepad抄下来每次copy & paste..其他的MFC DLL Wizard已经做好的, output base address好象也不完全必须.. //Entities.cpp<BR>//AutoCAD数据库初级操作实例——创建实钵、层、新组词典等,<BR>//在AutoCAD命令行中运行MakeNewEnts即可<BR>//包含头文件<BR>#include <string.h><BR>#include <aced.h><BR>#include <dbents.h><BR>#include <dbsymtb.h><BR>#include <dbgroup.h><BR>#include <dbapserv.h>
//函数声明<BR>AcDbObjectId createNewLine();<BR>AcDbObjectId createNewCircle();<BR>AcDbObjectId createNewLayer();<BR>void createNewGroup();<BR>Acad::ErrorStatus changeColor(AcDbObjectId,Adesk::UInt16);
//创建直线对象,并返回对象ID<BR>AcDbObjectId CreateNewLine()<BR>{<BR>//定义直线的起点、终点<BR>AcGePoint3d startPoint(5.0,4.0,0.0);<BR>AcGePoint3d endPoint(15.0,10.0,0.0);<BR>//初始化直线对象实例<BR>AcDbLine* pLine=new AcDbLine(startPoint,endPoint);<BR>//打开块表<BR>AcDbBlockTable *pBlockTable;<BR>acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForRead);<BR>//打开模型空间块表段,获得当前块表记录,并关闭块表<BR>AcDbBlockTableRecord *pBlockTableRecord;<BR>pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR>pBlockTable->close();<BR>//向当前块表记录中添加直线对象<BR>AcDbObjectId lineId;<BR>pBlockTableRecord->appendAcDbEntity(lineId,pLine);<BR>//关闭块表记录及直线对象<BR>pBlockTableRecord->close();<BR>pLine->close();<BR>//返回直线对象ID<BR>return lineId;<BR>}
<BR>//创建圆对象,并返回对象ID<BR>AcDbObjectId CreateNewCircle()<BR>{<BR>//定义圆心、法向向量<BR>AcGePoint3d center(10.0,7.0,0.0);<BR>AcGeVector3d normal(0.0,0.0,1.0);<BR>//初始化圆对象实例<BR>AcDbCircle *pCirc=new AcDbCircle(center,normal,4.5);<BR>//打开块表<BR>AcDbBlockTable *pBlockTable;<BR>acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForRead);<BR>//打开模型空间块表,获得当前块表记录,并关闭块表<BR>AcDbBlockTableRecord *pBlockTableRecord;<BR>pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR>pBlockTable->close();<BR>//向当前块表记录中添加圆对象<BR>AcDbObjectId CircleId;<BR>pBlockTableRecord->appendAcDbEntity(CircleId,pCirc);<BR>//关闭块表记录及圆对象<BR>pBlockTableRecord->close();<BR>pCirc->close();<BR>//返回圆对象ID<BR>return CircleId;<BR>}
//建立名为“MYNewLayer”的新层<BR>AcDbObjectId createNewLayer()<BR>{<BR>//打开层表,打开方式为只写<BR>AcDbLayerTable *pLayerTable;<BR>acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTable,AcDb::kForWrite);<BR>//初始化层表记录对象,并设定层表记录的名称“MYNewLayer”<BR>AcDbLayerTableRecord *pLayerTableRecord=new AcDbLayerTableRecord;<BR>//层的其它属性(例如颜色、线形等)都用缺省但,<BR>//如:颜色为white、线形为Continuous等<BR>//将新建的层表记录添加到层表中,并将层表记录的ID<BR>//保存到PLayerId作为函数的返回值<BR>AcDbObjectId pLayerId;<BR>pLayerTable->add(pLayerId,pLayerTableRecord);<BR>//关闭层表和层表记录对象<BR>pLayerTable->close();<BR>pLayerTableRecord->close();<BR>return pLayerId;<BR>}
//建立新组词典条目,利用第三个参数可以改变组的层属性<BR>void createNewGroup(AcDbObjectIdArray& objIds,char* pGroupName,AcDbObjectId pLayerId)<BR>{<BR>//初始化组对象实例,以参数pGroupName为组名<BR>AcDbGroup *pGroup= new AcDbGroup(pGroupName);<BR>//向组对象中加入实体<BR>for(int i=0;i<objIds.length();i++)<BR> pGroup->append(objIds);<BR>//打开组词典(存放于对象词典中)<BR>AcDbDictionary* pGroupDict;<BR>acdbHostApplicationServices()->workingDatabase()->getGroupDictionary(pGroupDict,AcDb::kForWrite);<BR>//将新建的组词典条的R入到组词典中<BR>AcDbObjectId pGroupId;<BR>pGroupDict->setAt(pGroupName,pGroup,pGroupId);<BR>//将组pGroup的层属性修改为PLayerld所代表的层<BR>pGroup->setLayer(pLayerId);<BR>//关闭组词典和组词典对象<BR>pGroupDict->close();<BR>pGroup->close();<BR>}<BR>//修改实体对象颜色,并返回一个状态码<BR>Acad::ErrorStatus<BR>changeColor(AcDbObjectId endId,Adesk::UInt16 newColor)<BR>{<BR>//定义一个实体对象,并利用参数endId打开这个实体对象<BR>AcDbEntity *pEntity;<BR>acdbOpenObject(pEntity,endId,AcDb::kForWrite);<BR>//修改实体对象的颜色<BR>pEntity->setColorIndex(newColor);<BR>//关闭实体对象<BR>pEntity->close();<BR>//返回Acad::eOK,对于有容错处理的程序,可能在函数当中就返回另外的状态码<BR>return Acad::eOk;<BR>}
//命令MakeNewEnts的执行函数<BR>void runIt()<BR>{<BR>//创建新层<BR>AcDbObjectId newLayerId=createNewLayer();<BR>//定义一个对象Id序列idArray<BR>AcDbObjectIdArray idArray;<BR>//创建一条直线和一个圆<BR>//将新建的直线、圆对象加入idArray中<BR>idArray.append(createNewLine());<BR>idArray.append(createNewCircle());<BR>//由于新建的两个对象均在0层,他们的缺省颜色为ByLayer<BR>//将直线对象的颜色该为红色(1)<BR>//将圆对象的颜色该为绿色(3)<BR>changeColor(idArray.first(),1);<BR>changeColor(idArray.last(),3);<BR>//将直线和圆对象放到组“MyNewGroup”中,<BR>//并将组的层属性改为“MyewGroup”层,<BR>//组中的两个实体对象的层属性也相应的改为“MyNewGroup”层<BR>//创建新层的函数也可以写成带名称参数<BR>createNewGroup(idArray,"MyNewGroup",newLayerId);<BR>}
//初始化函数<BR>void initApp()<BR>{<BR> acedRegCmds->addCommand("ASDK_MAKE_ENTITIES",<BR> "ASDK_MakeNewEnts","MakeNewEnts",ACRX_CMD_MODAL,runIt);<BR>}
//卸载函数<BR>void unloadApp()<BR>{<BR> acedRegCmds->removeGroup("ASDK_MAKE_ENTITIES");<BR>}
//应用程序主函数<BR>extern "C" AcRx::AppRetCode<BR>acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)<BR>{<BR> switch (msg) <BR> {<BR> case AcRx::kInitAppMsg:<BR> acrxDynamicLinker->unlockApplication(appId);<BR> acrxDynamicLinker->registerAppMDIAware(appId);<BR> //调用initApp()函数<BR> initApp();<BR> break;<BR> case AcRx::kUnloadAppMsg:<BR> //调用unloadApp()函数<BR> unloadApp();<BR> break;<BR> }<BR> return AcRx::kRetOK;<BR>} --------------------Configuration: EntitiesARX - Win32 Debug--------------------<BR>Compiling...<BR>Entities.cpp<BR>Linking...<BR> Creating library Debug/Entities.lib and object Debug/Entities.exp<BR>Entities.obj : error LNK2001: unresolved external symbol "class AcDbObjectId __cdecl createNewCircle(void)" (<A href="mailto:?createNewCircle@@YA?AVAcDbObjectId@@XZ" target="_blank" >?createNewCircle@@YA?AVAcDbObjectId@@XZ</A>)<BR>Entities.obj : error LNK2001: unresolved external symbol "class AcDbObjectId __cdecl createNewLine(void)" (<A href="mailto:?createNewLine@@YA?AVAcDbObjectId@@XZ" target="_blank" >?createNewLine@@YA?AVAcDbObjectId@@XZ</A>)<BR>.\Entities.arx : fatal error LNK1120: 2 unresolved externals<BR>Error executing link.exe.
Entities.arx - 3 error(s), 0 warning(s)<BR> LIBRARY "Entities"<BR>EXPORTS<BR> acrxEntryPoint PRIVATE<BR> acrxGetApiVersion PRIVATE
抓狂..免费帮你debug么?
大小写问题..//函数声明<BR>AcDbObjectId <FONT color=#ff0000>c</FONT>reateNewLine();<BR>AcDbObjectId <FONT color=#ff0000>c</FONT>reateNewCircle();
//创建直线对象,并返回对象ID<BR>AcDbObjectId <FONT color=#ff0000>C</FONT>reateNewLine()<BR>{
//创建圆对象,并返回对象ID<BR>AcDbObjectId <FONT color=#ff0000>C</FONT>reateNewCircle()<BR>{<BR><BR>所以在linking的时候会找不到函数定义(unresolved symbol,即不明标识).
强烈建议要练ARX的人都先熟悉一下VC++的报错系统.. 让你费心 我要好好学习 呵呵
页:
[1]