2011-12-02 63 views
0

我一直希望能夠在Matlab中使用[這個漂亮的C++ dll] [1],因爲我已經有了一些現有的Matlab的東西,我認爲可以從這個庫的功能中受益。但是,每當我運行此命令加載庫:在Matlab中加載.dll會導致'找不到類型'問題

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

我得到關於在DLL中使用的類型的所有腦幹警告討厭的ammount的,和一個瘋狂的數字語法錯誤,從未知類型明顯詞幹。這裏的警告/錯誤的開始:

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無法識別類型以及如何解決問題的任何想法?

+0

是否應該有一個DLL的鏈接? – Nzbuu

+0

這裏有一個鏈接,您可以下載構建dll的項目的網站:http://graphics.stanford.edu/~mdfisher/GameAIs.html – zergylord

回答

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兼容。

+0

是否需要通過loadlibrary加載相關的dll,或者只是在搜索路徑上?後一個選項不會改變我得到的錯誤: -/ – zergylord

+0

要在搜索路徑上回答,可以考慮addpath(http://www.mathworks.com/help/techdoc/ref/addpath.html)函數。但在我的更新中,我想知道爲什麼在上面的錯誤消息中創建thunk文件時出錯。這是在matlab文檔中陳述「MATLAB生成一個thunk文件,這是一個兼容層到您的64位庫。」。無論如何,如果難以生成thunk文件,您可以創建一個由matlab調用的適配器dll,它調用實際的dll(適配器應該是簡單的代碼,以便matlab可以生成thunk dll)。 – kuskus

+0

我認爲thunk問題(以及所有其他錯誤)只是Matlab的類型替換的副產品。我已經加載了其他庫沒有thunk問題,所以我不認爲這就是它。 – zergylord

相關問題