【问题标题】:CANoe - Could not open .dll in CAPL scriptCANoe - 无法在 CAPL 脚本中打开 .dll
【发布时间】: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,你想将其发布为答案以便我接受吗?

标签: c++ dll capl canoe


【解决方案1】:

在 (-1,-1) 处出现警告 2102:无法打开 C:\Program Files\Vector CANoe 10.0\Exec64\LAD.dll

此类错误的一个可能原因是您混合使用了 32 位和 64 位。请记住,64 位应用程序不能直接加载 32 位 dll。 32 位应用程序和 64 位 dll 也是如此。你不能混合这些。

其他可能性可能是损坏的 dll、可能缺少 dll 的依赖 dll 或可能缺少插件机制可能需要的导出函数。

在这种情况下,已在 cmets 中验证问题是混合了 32 位和 64 位可执行文件。

【讨论】:

    猜你喜欢
    • 2020-08-22
    • 2020-06-23
    • 2016-12-23
    • 2021-04-06
    • 1970-01-01
    • 2021-08-27
    • 2018-12-21
    • 1970-01-01
    • 2018-06-15
    相关资源
    最近更新 更多