【发布时间】:2020-10-16 04:57:14
【问题描述】:
我正在尝试包含我自己的 .dll 文件并将其函数导出到我的 CAPL 脚本。
我很确定我的 .dll 文件编写正确,这里是相关代码,其中一些是从文档中复制/粘贴的:
#include "pch.h"
#include "CDLL.h"
long CAPLEXPORT far CAPLPASCAL addCAPL(long a, long b) {
return a + b;
}
#ifdef __BCPLUSPLUS__
#pragma warn -pin
#endif
// Define how to export functions to capl,
// Arg0 = name, arg1=function, arg2=return type, arg3=# of params, arg4=type of params, args5=depth of param if array (aboslutely useless as c++ cannot used 2+D arrays as params without knowing the dimensions)
CAPL_DLL_INFO CAPL_DLL_INFO_LIST[] = {
{CDLL_VERSION_NAME,(CAPL_FARCALL)CDLL_VERSION, CAPL_DLL_CDECL, 0xabcd,CDLL_EXPORT},
{"Add", (CAPL_FARCALL)addCAPL, 'L', 2, "LL", "\x0\x0"},
{0,0}
};
// Magic export table to capl function?
unsigned long CAPLEXPORT __cdecl caplDllGetTable(void)
{
return (unsigned long)CAPL_DLL_INFO_LIST;
}
我正在使用一个简单的加法器函数进行测试。包含所需的 CDLL.h,cpp 代码成功编译为 .dll (LAD.dll)。
在 CANoe 中,我在选项 -> 编程 -> CAPL DLLs 下添加了模拟和测量模式下的 .dll 文件。该文件位于 CANoe 安装的 exec32 文件中,只是为了确定(和 exec64)。
当我编译我的 CAPL 脚本时,我收到警告:
Warning 2102 at (-1,-1): Could not open C:\Program Files\Vector CANoe 10.0\Exec64\LAD.dll, . Logger.can
这反过来意味着我无法在我的 CAPL 脚本中使用导出的“Add()”函数,因为它找不到该函数。
我已阅读有关 CANoe 插件的所有文档,并阅读了三个存在类似问题的堆栈溢出问题,但无济于事。如果我移动或重命名 .dll CAPL,则会警告找不到该文件。我已经编辑了 LAD.dll 的权限以允许任何程序完全修改访问。
我意识到这可能有点晦涩难懂,但我将非常感谢您对此事的任何帮助。我真的在拔头发,因为感觉我做的一切都是正确的。
【问题讨论】:
-
无法打开可能意味着您正在混合 32 位和 64 位。
-
@drescherjm 非常感谢!我打算构建一个 32 位 .dll 但使用 64 位 CANoe,你想将其发布为答案以便我接受吗?