Error using calllib Too many inputs passed to SimpleFunctionThunk.

5 visualizzazioni (ultimi 30 giorni)
I am using the calllib function to call on my 64-bit C++ lib. I am using Matlab R2015a. The prototype used to load the library using the loadlibrary function is
ival={cell(1,1)};
fcns=struct('name',ival,'calltype',ival,'LHS',ival,'RHS',ival,'alias',ival);
structs=[];
enuminfo=[];
fcns.name{1}='MyFunc'; fcns.calltype{1}='cdecl'; fcns.LHS{1}='doublePtr'; fcns.RHS{1}={ ...
'stringPtr' , 'int32Ptr' , 'stringPtr' , ...
'int32Ptr' , 'stringPtr' , 'int32Ptr' , ...
'int32Ptr' , 'doublePtr' , 'int32Ptr'};
methodinfo=fcns;
After the loadlibrary, I have verified that its loaded using the libfunctionsview function. After the call is made, i get the following error
Error using calllib
Too many inputs passed to SimpleFunctionThunk.
Please let me know if there is any fix to this issue.
-Sahil

Risposta accettata

sahil gandhi
sahil gandhi il 30 Gen 2018
Its been a while, but a colleague connected with me for the same issue, and I thought to document the resolution, so here it goes..
  • Ensure that along with the dll you have the following files
  1. The header (.h) file for the function you are calling in the same location
  2. The TFLib.dll for the dll
  • When you create a prototype for the function in matlab it should look something like this
function [methodinfo,structs,enuminfo, ThunkLibName]=Prototype
ival={cell(1,1)};
fcns=struct('name',ival,'calltype',ival,'LHS',ival,'RHS',ival,'alias',ival, 'thunkname', ival);
structs=[];
enuminfo=[];
%MfilePath=fileparts(mfilename('fullpath'));
ThunkLibName='C:\Works\SampleCode\TFLib';
fcns.thunkname{1}=''; fcns.name{1}='MyFunc'; fcns.calltype{1}='Thunk'; fcns.LHS{1}='doublePtr'; fcns.RHS{1}={ ...
'stringPtr' , 'int32Ptr' , 'stringPtr' , ...
'int32Ptr' , 'stringPtr' , 'int32Ptr' , ...
'int32Ptr' , 'doublePtr' , 'int32Ptr'};
methodinfo=fcns;
Note: Compare with the prototype in the question to see the difference.
  • In the loadlibrary call, pass the header (.h) file. The dll name in this example is SampleCode.dll in the following location "C:\Works\SampleCode"
loadlibrary 'C:\Works\SampleCode\SampleCode' 'C:\Works\SampleCode\SampleCode.h';
  • C++ Compiler needs to be installed which is part of the Windows SDK 7.1. The following steps need to be followed
  1. Remove the following from if already installe
  2. Microsoft Visual Studio 2010 C++ Redistributable
  3. Anything above Microsoft .Net 4.0 Framework
  4. Install Microsoft .Net 4.0 Framework
  5. Install the Windows SDK 7.1
  6. Ensure that the C++ Compiler options is enabled
  7. Ensure that the installation is successful
  8. Run the “mex -setup c++”.
  9. Check for the following messageMEX configured to use 'Microsoft Windows SDK 7.1 (C++)' for C++ language compilation.
  10. Now install the updates to C++ Redistributables and .Net framework if desired.
Hope this works fine, and resolves the issue. Feel free to post a comment/corrections.

Più risposte (1)

Philip Borghesani
Philip Borghesani il 18 Ago 2015
Calltype of 'cdecl' is not supported on 64 bit systems however it does work for simple functions with a limited number of integer and pointer arguments. You will need to use a thunkfile to call this function. Try loading your file with a new loadlibrary command starting from scratch and examine the generated prototype information and thunk file.

Categorie

Scopri di più su C Shared Library Integration in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by