DLL函数名称与导出的不同

时间:2015-07-16 17:26:55

标签: c++ matlab dll mex dumpbin

我正在使用由其他人使用c ++和matlab开发的程序。我有两者的源代码,但我不知道发生了什么......

Matlab使用以下内容调用从c ++生成的dll:

myCustomCppFunction('param1', 'param2)

我希望在dll导出中看到 myCustomCppFunction ,但我找不到它。

当我运行 dumpbin 命令时,我收到类似这样的内容:

dumpbin /exports c:/myCustomCpp.dll
ordinal hint RVA      name
1    0 00001010 myCustomCppFunctionWithADifferentName

所以,

myCustomCppFunctionWithADifferentName!= myCustomCppFunction

DLL导出的函数名称与我的matlab调用的函数名称不同。而且我不是在谈论受损的名字,两个名字都是100%不同,比如'apple'和'banana'。 : - )

不知何故,一切正常!但是如何?!?

在Matlab中,我还运行了哪个命令,向我确认调用的函数来自我正在调查的DLL ......

>> which myCustomCppFunctionWithADifferentName
>> c:/myCustomCpp.dll

任何线索?

1 个答案:

答案 0 :(得分:1)

除了您的标记外,我不确定您是否处理过MEX文件。

MEX文件(DLL)的名称与导出函数的名称无关。 MEX文件中的导出函数是:

mexFunction

在Windows中,仍有DLLMain,但 MATLAB会查找mexFunction

所以这就是:

>> myMEXFunction()  % looks for myMEXFunction.mexw64 (or whatever extension)

如果myMEXFunction.mexw64导出了mexFunction,那么您就可以了。

请注意,mexFunctionmex.h extern "C"中声明为<{1}}(如果您正在编译.cpp),您只需 define 它在你的来源。所以它永远都是未修饰的。

但是,你的myCustomCpp.dll不会导出mexFunction,所以也许你不是在谈论MEX文件?另外,如果您正在谈论MEX文件,那么让我更加不确定的是which带来的奇怪结果。您的MATLAB源代码(myCustomCppFunction)是否实际使用loadlibrarycalllib来操作DLL?如果myCustomCppFunction()以这种方式加载非MEX DLL,那么你所展示的内容是有意义的。

相关问题