在Matlab中加载.dll会导致“找不到类型”问题

时间:2011-12-02 07:11:09

标签: c++ matlab dll

我一直希望在Matlab中使用[这个漂亮的C ++ dll] [1],因为我有一些现有的Matlab,我认为可以从这个库的功能中受益。但是,每当我运行此命令加载库时:

loadlibrary('d3d9Callback.lib','d3d9Callback.h')

关于dll中使用的类型的存在,我得到了一个令人讨厌的大量警告,以及一些疯狂的语法错误,显然源于未知类型。这是警告/错误的开始:

   Warning: Warnings messages were produced while parsing.  Check the functions you
intend to use for correctness.  Warning text can be viewed using:
[notfound,warnings]=loadlibrary(...) 
> In loadlibrary at 360
Error loading library intermediate output follows.
The actual error is at the end of this output.
*********

Type 'intCONSTDWORDPtr' was not found.  Defaulting to type voidPtr.

Found on line 29 of input from line 28 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLE' was not found.  Defaulting to type error.

Found on line 29 of input from line 28 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTDWORDPtr' was not found.  Defaulting to type voidPtr.

Found on line 30 of input from line 29 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLE' was not found.  Defaulting to type error.

Found on line 30 of input from line 29 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DSURFACE_DESCPtr' was not found.  Defaulting to type voidPtr.

Found on line 35 of input from line 34 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'BitmapPtr' was not found.  Defaulting to type voidPtr.

Found on line 35 of input from line 34 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLE' was not found.  Defaulting to type error.

Found on line 35 of input from line 34 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'BufferLockDataPtr' was not found.  Defaulting to type voidPtr.

Found on line 36 of input from line 35 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DVERTEXBUFFER_DESCPtr' was not found.  Defaulting to type voidPtr.

Found on line 36 of input from line 35 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'BufferLockDataPtr' was not found.  Defaulting to type voidPtr.

Found on line 37 of input from line 36 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DINDEXBUFFER_DESCPtr' was not found.  Defaulting to type voidPtr.

Found on line 37 of input from line 36 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLE' was not found.  Defaulting to type error.

Found on line 39 of input from line 38 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLEPtr' was not found.  Defaulting to type voidPtr.

Found on line 44 of input from line 43 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTD3DVIEWPORT9Ptr' was not found.  Defaulting to type voidPtr.

Found on line 46 of input from line 45 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DTRANSFORMSTATETYPE' was not found.  Defaulting to type error.

Found on line 47 of input from line 46 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTD3DMATRIXPtr' was not found.  Defaulting to type voidPtr.

Found on line 47 of input from line 46 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DVERTEXELEMENT9Ptr' was not found.  Defaulting to type voidPtr.

Found on line 49 of input from line 48 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLE' was not found.  Defaulting to type error.

Found on line 51 of input from line 50 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTD3DLIGHT9Ptr' was not found.  Defaulting to type voidPtr.

Found on line 54 of input from line 53 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'BOOL' was not found.  Defaulting to type error.

Found on line 55 of input from line 54 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTD3DMATERIAL9Ptr' was not found.  Defaulting to type voidPtr.

Found on line 57 of input from line 56 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DRENDERSTATETYPE' was not found.  Defaulting to type error.

Found on line 59 of input from line 58 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DTEXTURESTAGESTATETYPE' was not found.  Defaulting to type error.

Found on line 60 of input from line 59 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLE' was not found.  Defaulting to type error.

Found on line 62 of input from line 61 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLE' was not found.  Defaulting to type error.

Found on line 64 of input from line 63 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLE' was not found.  Defaulting to type error.

Found on line 65 of input from line 64 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTBOOLPtr' was not found.  Defaulting to type voidPtr.

Found on line 67 of input from line 66 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTfloatPtr' was not found.  Defaulting to type voidPtr.

Found on line 68 of input from line 67 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTUINTPtr' was not found.  Defaulting to type voidPtr.

Found on line 69 of input from line 68 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTBOOLPtr' was not found.  Defaulting to type voidPtr.

Found on line 71 of input from line 70 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTfloatPtr' was not found.  Defaulting to type voidPtr.

Found on line 72 of input from line 71 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTUINTPtr' was not found.  Defaulting to type voidPtr.

Found on line 73 of input from line 72 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'HANDLE' was not found.  Defaulting to type error.

Found on line 75 of input from line 74 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DPRIMITIVETYPE' was not found.  Defaulting to type error.

Found on line 80 of input from line 79 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DPRIMITIVETYPE' was not found.  Defaulting to type error.

Found on line 81 of input from line 80 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DPRIMITIVETYPE' was not found.  Defaulting to type error.

Found on line 82 of input from line 81 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'INT' was not found.  Defaulting to type error.

Found on line 82 of input from line 81 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DPRIMITIVETYPE' was not found.  Defaulting to type error.

Found on line 83 of input from line 82 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTvoidPtr' was not found.  Defaulting to type voidPtr.

Found on line 83 of input from line 82 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DPRIMITIVETYPE' was not found.  Defaulting to type error.

Found on line 84 of input from line 83 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTvoidPtr' was not found.  Defaulting to type voidPtr.

Found on line 84 of input from line 83 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DFORMAT' was not found.  Defaulting to type error.

Found on line 84 of input from line 83 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTvoidPtr' was not found.  Defaulting to type voidPtr.

Found on line 84 of input from line 83 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTRECTPtr' was not found.  Defaulting to type voidPtr.

Found on line 89 of input from line 88 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTRECTPtr' was not found.  Defaulting to type voidPtr.

Found on line 89 of input from line 88 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'intCONSTD3DRECTPtr' was not found.  Defaulting to type voidPtr.

Found on line 90 of input from line 89 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Type 'D3DCOLOR' was not found.  Defaulting to type error.

Found on line 90 of input from line 89 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h

Failed to parse type 'D3D9Base :: LPDIRECT3DDEVICE9 Device' original input 'D3D9Base :: LPDIRECT3DDEVICE9 Device '
Found on line 101 of input from line 100 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h
Error parsing argument for function ReportCreateDevice function may be invalid.

Type 'ID3D9DeviceOverlayPtr' was not found.  Defaulting to type voidPtr.

Found on line 101 of input from line 100 of file C:\\Users\\Steven\\Dropbox\\Stanford_SC2bot\\D3D9CallbackSC2\\Base\\d3d9Callback.h
*********
??? Error using ==> loadlibrary at 441
Building d3d9Callback_thunk_pcwin64 failed.  Compiler output is:
cl -I"C:\Program Files\MATLAB\R2011a\extern\include"  /Zp8  /W3  /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0  /nologo  -I"C:\Users\Steven\Dropbox"
-I"C:\Users\Steven\Dropbox\Stanford_SC2bot\D3D9CallbackSC2\Base" "d3d9Callback_thunk_pcwin64.c" -LD -Fe"d3d9Callback_thunk_pcwin64.dll"
d3d9Callback_thunk_pcwin64.c
C:\Users\Steven\Dropbox\Stanford_SC2bot\D3D9CallbackSC2\Base\d3d9Callback.h(28) : error C2146: syntax error : missing ')' before identifier 'DWORD'
C:\Users\Steven\Dropbox\Stanford_SC2bot\D3D9CallbackSC2\Base\d3d9Callback.h(28) : error C2061: syntax error : identifier 'DWORD'
C:\Users\Steven\Dropbox\Stanford_SC2bot\D3D9CallbackSC2\Base\d3d9Callback.h(28) : error C2059: syntax error : ';'

现在我已经检查了Matlab论坛并尝试了常见的嫌疑人(设置c ++编译器,确保它不是32位Matlab上的64位dll,并确保dll是'extern c')。我开始认为问题在于问题是dll大量来自directx库以及来自同一网站的额外dll。也许Matlab不了解它们,这导致了“类型未知”的问题?这是我唯一能想到的,但它对我来说没有意义,因为加载的库已经编译成了一个dll。

无论如何,我对处理dll很陌生,所以我的直觉可能已经过时了。有关为什么Matlab无法识别类型以及如何解决问题的任何想法?

1 个答案:

答案 0 :(得分:1)

从这discussion开始!在SO上,看起来导出的dll函数是C函数,而不是matlab中loadLibrary的C ++函数。

同样在错误消息的末尾,它似乎是另一个dll(d3d9Callback_thunk_pcwin64.dll),并且缺少一些包含文件,因此编译错误。确保要在matlab中加载的库具有可用于matlab搜索路径的相关dll。

<强>更新

阅读一些评论后in matlab forum!要了解d3d9Callback_thunk_pcwin64的来源,有点奇怪,因为你提到你已经确认了64位dll和32位matlab兼容性。