明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2872|回复: 5

.def文件调试问题

[复制链接]
发表于 2005-3-15 20:25:00 | 显示全部楼层 |阅读模式
按照手册上写的,编译的时候,def错了,提示 perateDb.def : error LNK2001: 无法解析的外部符号 acrxEntryPoint
Debug/OperateDB.lib : fatal error LNK1120: 1 个无法解析的外部命令
LINK : fatal error LNK1141: 导出文件生成期间失败 生成日志保存在“file://h:\VCarx\2004training\chapter4\OperateDB\Debug\BuildLog.htm”中
OperateDB - 3 错误,1 警告
---------------------- 完成 --------------------- 生成:0 已成功, 1 已失败, 0 已跳过 源代码如下,请问是什么问题 LIBRARY OperateDB
DESCRIPTION 'Operate(readwirte) on AutoCAD AcDbDatabase'
EXPORTS
acrxEntryPoint PRIVATE
acrxGetApiVersion PRIVATE
发表于 2005-3-15 23:44:00 | 显示全部楼层

reply

acrxEntryPoint这个入口函数定义了没有,参见arx帮助:
#include "stdafx.h"
#include <aced.h>
#include <rxregsvc.h>
Next, we declare two functions:
  • initApp() - which will be called by AutoCAD when our application is loaded and
  • unloadApp() - which is called when our application is unloaded.
Please refer to the acrxEntryPoint() function below to see how these functions are being called by AutoCAD. Add the lines:
void initApp();
void unloadApp();
Next, we declare our own function to print "Hello world!" on the AutoCAD command line. Add:
void helloWorld();
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:
void initApp()
{
// register a command with the AutoCAD command mechanism
acedRegCmds->addCommand("HELLOWORLD_COMMANDS",
"Hello",
"Bonjour",
ACRX_CMD_TRANSPARENT,
helloWorld);
}
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:
void unloadApp()
{
acedRegCmds->removeGroup("HELLOWORLD_COMMANDS");
}
Next we define our helloWorld() function; acutPrintf() is the equivalent of the C printf function redirected to the AutoCAD command line. Add:
void helloWorld()
{
acutPrintf("\nHello World!");
}
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. NOTE: 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:
acrxEntryPoint入口函数:
extern "C" AcRx::AppRetCode
acrxEntryPoint(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; }
DEF定义:
  • acrxEntryPoint
  • acrxGetApiVersion.
LIBRARY Step01
EXPORTS
acrxEntryPoint PRIVATE
acrxGetApiVersion PRIVATE
 楼主| 发表于 2005-3-16 09:15:00 | 显示全部楼层
< style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">extern


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


< style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: SimSun; mso-outline-level: 1">请问是什么原因,是因为版本变化,修改了吗?
发表于 2005-3-16 10:11:00 | 显示全部楼层
ericyu发表于2005-3-15 20:25:00回复:(ericyu).def文件调试问题按照手册上写的,编译的时候,def错了,提示 perateDb.def : error LNK2001: 无法解析的外部符号 acrxEntryPointDebug/OperateDB.lib : fatal error LN
楼主在project->settings->link里加了ARX的那一堆library modules没有.. 这个函数没记错的话应该是acrx15.lib负责出口的.. registerAppMDIAware和这事没关..
 楼主| 发表于 2005-3-16 14:43:00 | 显示全部楼层
我用的是arx2004,没有acrx15.lib


但是事实就是,两个程序完全一样,就这里不同,就不能通过没什么?
发表于 2005-3-17 10:19:00 | 显示全部楼层
ericyu发表于2005-3-16 14:43:00我用的是arx2004,没有acrx15.lib 但是事实就是,两个程序完全一样,就这里不同,就不能通过没什么?
汗..程序样子长得一样, 后面compile / link setting可以大不同的..我的意思是这个错误不是程序的错误..ARX程序需要一堆的外加.lib文件, 必须每一个程序都设定, 不设定的话C++就不认识ARX的函数罢了.. 楼主再到ARX的文件夹下面去看看, 里面至少应该有一个叫lib的文件夹, 如果acrx15.lib在arx2004里头改了名字, 至少应该还是放在那个文件夹里的..
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 07:33 , Processed in 0.191931 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表