ericyu 发表于 2005-3-15 20:25:00

.def文件调试问题

按照手册上写的,编译的时候,def错了,提示


perateDb.def : error LNK2001: 无法解析的外部符号 acrxEntryPoint<BR>Debug/OperateDB.lib : fatal error LNK1120: 1 个无法解析的外部命令<BR>LINK : fatal error LNK1141: 导出文件生成期间失败


生成日志保存在“file://h:\VCarx\2004training\chapter4\OperateDB\Debug\BuildLog.htm”中<BR>OperateDB - 3 错误,1 警告


<BR>---------------------- 完成 ---------------------


                       生成:0 已成功, 1 已失败, 0 已跳过



源代码如下,请问是什么问题


LIBRARY        OperateDB<BR>DESCRIPTION 'Operate(readwirte) on AutoCAD AcDbDatabase'<BR>EXPORTS<BR>                acrxEntryPoint        PRIVATE<BR>                acrxGetApiVersion        PRIVATE<BR>

王咣生 发表于 2005-3-15 23:44:00

reply

acrxEntryPoint这个入口函数定义了没有,参见arx帮助:



<TABLE cols=1 width="100%" bgColor=#c0c0c0 NOWRAP>
<TBODY>
<TR>
<TD width="100%" bgColor=#c0c0c0><CODE>#include "stdafx.h"<BR>#include &lt;aced.h&gt;<BR>#include &lt;rxregsvc.h&gt;</CODE></TD></TR></TBODY></TABLE>


Next, we declare two functions:
<UL>
<LI>initApp() - which will be called by AutoCAD when our application is loaded and
<LI>unloadApp() - which is called when our application is unloaded. </LI></UL>
Please refer to the acrxEntryPoint() function below to see how these functions are being called by AutoCAD. Add the lines:<BR>       
<TABLE cols=1 width="100%" bgColor=#c0c0c0 NOWRAP>
<TBODY>
<TR>
<TD width="100%" bgColor=#c0c0c0><CODE>void initApp();<BR>void unloadApp();</CODE></TD></TR></TBODY></TABLE>
       
Next, we declare our own function to print "Hello world!" on the AutoCAD command line. Add:<BR>       
<TABLE cols=1 width="100%" bgColor=#c0c0c0 NOWRAP>
<TBODY>
<TR>
<TD width="100%" bgColor=#c0c0c0><CODE>void helloWorld();</CODE></TD></TR></TBODY></TABLE>
       
Now we will define the initApp() function. This function registers a new command with the AutoCAD command mechanism. This new command will become an additional entry point into our application:<BR>       
<TABLE cols=1 width="100%" bgColor=#c0c0c0 NOWRAP>
<TBODY>
<TR>
<TD width="100%" bgColor=#c0c0c0><CODE>void initApp()<BR>{</CODE>
<BLOCKQUOTE>
<CODE>// register a command with the AutoCAD command mechanism<BR>acedRegCmds-&gt;addCommand("HELLOWORLD_COMMANDS",<BR>"Hello",<BR>"Bonjour",<BR>ACRX_CMD_TRANSPARENT,<BR>helloWorld);</CODE>

</BLOCKQUOTE>
<CODE>}</CODE>

</TD></TR></TBODY></TABLE>
       
For details regarding the acedRegCmds macro and the addCommand() method (of AcEdCommandStack class), please refer to the ObjectARX online help file. The first argument of addCommand() is the command group name (it includes only one command in our case). The second argument is the global/un-translated command name. The third argument is the local/translated name for the same command. The fourth argument is the command flag (note that here we define a transparent command, which means that the command can be invoked while another command is active). Finally, the last argument is the pointer to the function being called by our command. In C++ this is the function name itself.
Next we define the unloadApp() function. This function will remove our command group, which will also remove our command. Since commands registered with AutoCAD become additional entry points into our application, it is absolutely necessary to remove them when the application is unloaded. Add:<BR>       
<TABLE cols=1 width="100%" bgColor=#c0c0c0 NOWRAP>
<TBODY>
<TR>
<TD width="100%" bgColor=#c0c0c0><CODE>void unloadApp()<BR>{</CODE>
<BLOCKQUOTE>
<CODE>acedRegCmds-&gt;removeGroup("HELLOWORLD_COMMANDS");</CODE>

</BLOCKQUOTE>
<CODE>}</CODE>

</TD></TR></TBODY></TABLE>
Next we define our helloWorld() function; acutPrintf() is the equivalent of the C printf function redirected to the AutoCAD command line. Add:<BR>       
<TABLE cols=1 width="100%" bgColor=#c0c0c0 NOWRAP>
<TBODY>
<TR>
<TD width="100%" bgColor=#c0c0c0><CODE>void helloWorld()<BR>{</CODE>
<BLOCKQUOTE>
<CODE>acutPrintf("\nHello World!");</CODE>

</BLOCKQUOTE>
<CODE>}</CODE>

</TD></TR></TBODY></TABLE>
Pretty basic indeed!
Now we need to define the most important function for ObjectARX applications. All ObjectARX applications have one main entry point that is used for messaging: the acrxEntryPoint() function. Remember that an ObjectARX application is a DLL and thus does not have a main() entry point. AutoCAD calls the ObjectARX module acrxEntryPoint() function to pass messages to the application.
The first parameter of acrxEntryPoint() is a data member of the AcRx class called msg which represents the message sent from the ObjectARX kernel to the application. Refer to the online help for details about the different messages an ObjectARX application can receive from AutoCAD.
In our very simple example, we need to be notified when the application is loaded and unloaded in order to register and un-register our "hello" command. In the first case we will call our initApp() function; in the second case we will call our unloadApp() function.
The second parameter of acrxEntryPoint() is an opaque handle to data passed to different functions, such as the lock and unlock functions (this data changes depending on the message passed by AutoCAD).
By default applications are locked, which means that once loaded they cannot be unloaded. Since our application is very simple (it does not define objects that AutoCAD and other applications refer to, except our command), we can safely unlock our application to make it unloadable, provided that we remove our command first, which is achieved in our unloadApp() function.
Also by default, ObjectARX applications are not MDI aware (again, please refer to the online help for detailed information on the MDI issues). Applications need to register themselves explicitly as being MDI aware using the acrxRegisterAppMDIAware() global function.
<B>NOTE:</B> Registering an application as being MDI aware is not in itself enough for the application to be effectively MDI aware. The criteria that need to be met are described in details in the ObjectARX online documentation.
Since our application is very simple (it does not use the concept of Document and does not interact with the AutoCAD drawing database), we can safely register it as being MDI aware using the acrxRegisterAppMDIAware() global function. Add:<BR><FONT face=新宋体 color=#3d11ee><b>acrxEntryPoint入口函数:</b></FONT>       



<TABLE cols=1 width="100%" bgColor=#c0c0c0 NOWRAP>
<TBODY>
<TR>
<TD width="100%" bgColor=#c0c0c0><CODE>extern "C" AcRx::AppRetCode<BR>acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)<BR>{</CODE>
<BLOCKQUOTE>
<CODE><BR>switch (msg)<BR>{</CODE>


<BLOCKQUOTE>
<CODE><BR>case AcRx::kInitAppMsg:<BR>acrxDynamicLinker-&gt;unlockApplication(pkt);<BR>acrxRegisterAppMDIAware(pkt);<BR>initApp();<BR>break;<BR>case AcRx::kUnloadAppMsg:<BR>unloadApp();<BR>break;<BR>default:<BR>break;<BR></CODE>

</BLOCKQUOTE>
<CODE>}<BR></CODE>

</BLOCKQUOTE>
<CODE>return AcRx::kRetOK;</CODE>


<CODE>}</CODE>

</TD></TR></TBODY></TABLE>


<b><FONT color=#0909f7>DEF定义:</FONT></b>

<FONT face=新宋体>
<BLOCKQUOTE>
<UL>
<LI>acrxEntryPoint       
<LI>acrxGetApiVersion. </LI></UL></BLOCKQUOTE>

<TABLE cols=1 width="100%" bgColor=#000000 NOWRAP>
<TBODY>
<TR>
<TD width="100%" bgColor=#c0c0c0><CODE>LIBRARY Step01<BR>EXPORTS<BR>acrxEntryPoint PRIVATE<BR>acrxGetApiVersion PRIVATE</CODE></TD></TR></TBODY></TABLE>


</FONT>

ericyu 发表于 2005-3-16 09:15:00

<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">extern


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">"C" AcRx::AppRetCode


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">acrxEntrypoint(AcRx::AppMsgCode msg,void* pkt)


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">{


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">switch(msg) {


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">case AcRx::kInitAppMsg:


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: SimSun; mso-outline-level: 4">acrxDynamicLinker-&gt;unlockApplication(pkt);


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: SimSun; mso-outline-level: 4">acrxDynamicLinker-&gt;registerAppMDIAware(pkt);


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: SimSun; mso-outline-level: 4">initApp();


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">break;


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">case AcRx::kUnloadAppMsg:


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: SimSun; mso-outline-level: 4">unloadApp();


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: SimSun; mso-outline-level: 4">break;


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">default:


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">break;


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">}


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">return AcRx::kRetOK;


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">}


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">       


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">/*extern "C" AcRx::AppRetCode


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">{


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">switch (msg)


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">{


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">       


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">case AcRx::kInitAppMsg:


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">acrxDynamicLinker-&gt;unlockApplication(pkt);


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">acrxRegisterAppMDIAware(pkt);


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">initApp();


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">break;


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">case AcRx::kUnloadAppMsg:


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">unloadApp();


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">break;


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">default:


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: SimSun; mso-outline-level: 3">break;


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">}


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">       


<P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: SimSun; mso-outline-level: 2">return AcRx::kRetOK;


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">       


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">}


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">*/


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">我是参考arx2000的一本书做的,实际用的是arx2004


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">代码中acrxDynamicLinker-&gt;registerAppMDIAware(pkt);不同,导致分析不过去,


<P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">请问是什么原因,是因为版本变化,修改了吗?

pandoram 发表于 2005-3-16 10:11:00

ericyu发表于2005-3-15 20:25:00static/image/common/back.gif回复:(ericyu).def文件调试问题按照手册上写的,编译的时候,def错了,提示



perateDb.def : error LNK2001: 无法解析的外部符号 acrxEntryPointDebug/OperateDB.lib : fatal error LN


楼主在project-&gt;settings-&gt;link里加了ARX的那一堆library modules没有..


这个函数没记错的话应该是acrx15.lib负责出口的..


registerAppMDIAware和这事没关..<BR>

ericyu 发表于 2005-3-16 14:43:00

我用的是arx2004,没有acrx15.lib


但是事实就是,两个程序完全一样,就这里不同,就不能通过没什么?

pandoram 发表于 2005-3-17 10:19:00

ericyu发表于2005-3-16 14:43:00static/image/common/back.gif我用的是arx2004,没有acrx15.lib



但是事实就是,两个程序完全一样,就这里不同,就不能通过没什么?


汗..程序样子长得一样, 后面compile / link setting可以大不同的..我的意思是这个错误不是程序的错误..ARX程序需要一堆的外加.lib文件, 必须每一个程序都设定, 不设定的话C++就不认识ARX的函数罢了..


楼主再到ARX的文件夹下面去看看, 里面至少应该有一个叫lib的文件夹, 如果acrx15.lib在arx2004里头改了名字, 至少应该还是放在那个文件夹里的..<BR>
页: [1]
查看完整版本: .def文件调试问题