c# - 找不到 32 位 DLL 的入口点。使用 64 位 DLL

标签 c# c++ dll cuda 32bit-64bit

我们的团队开发了一个 C++ CUDA DLL 和一个使用我们的 DLL 的 C# .NET 4.5 HMI。

这些程序最初计划仅适用于 64 位平台。

最近我们的客户要求我们也为 32 位平台提供我们的开发。

我们设法编译了 32 位的 DLL 和 HMI。

所以我们现在有两种配置:

  • 使用 CUDA DLL x64 的 HMI x64
  • 使用 CUDA DLL x86 的 HMI x86

64 位配置完美运行。

32位配置有一些问题:

  • 只有一些导出函数可用
  • 不可用函数调用抛出异常: 中找不到入口点

使用 Dependency Walker 探索我们的 32 位和 64 位 dll 向我们展示了所有导出的函数。 (只有错位的名称在 32 位和 64 位之间变化)

以下是一些可用导出函数的原型(prototype):

extern "C" RetourInit __declspec(dllexport) __stdcall initGPU();
extern "C" Retour __declspec(dllexport) __stdcall setImageGpu(int idGPU, int nbImages, Image * listeImages);
extern "C" Retour __declspec(dllexport) __stdcall getImageGpu(int idGPU, int nbImages, Image * listeImages);
extern "C" Retour __declspec(dllexport) __stdcall duplicateImage(int idGPU, int nbImages, Image * listeImages);

以下是一些不可用导出函数的原型(prototype):

extern "C" Retour __declspec(dllexport) __stdcall decoupe(int idCarte, Decoupe paramDecoupe);
extern "C" Retour __declspec(dllexport) __stdcall fusion(int idCarte, Fusion paramFusion);

如果您有任何解决方案建议或问题,我们将很高兴听到。

谢谢大家。

最佳答案

问题是由于没有使用指针传递 Fusion 和 Decoupe 结构。

我们只是将原型(prototype)更改为:

extern "C" Retour __declspec(dllexport) __stdcall decoupe(int idCarte, Decoupe* paramDecoupe);
extern "C" Retour __declspec(dllexport) __stdcall fusion(int idCarte, Fusion* paramFusion);

并调整我们的 DLL 代码。我们的 C# HMI 没有改变。

此修改适用于 x86 和 x64

很奇怪 64 位平台不受此修改的影响...

感谢您的评论。

关于c# - 找不到 32 位 DLL 的入口点。使用 64 位 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24289496/

相关文章:

c# - 如何在单元测试中使用 AutoData 在测试参数中提供一个类型的 N 个对象?

C++从main()通过类函数传递指针

c++ - 我是否需要为右值引用显式地重载接受 const 左值引用的方法?

c# - 在 C# 中编写递归函数

c# - 为什么在这个例子中 "x ^= true"会产生 false?

c# - Windows 10 UWP,带有汉堡菜单的后退按钮到上一个框架

C++ 元编程 : overloading of arithmetic operators for types

c++ - 将 c++ dll 导入 vb.net 时,float*(图像类型)的等效数据类型是什么?

c++ - COM - 实现 DllGetClassObject

java - 如何将 win32com.dll 包含到 jar 文件中?