Calling C/C++ libraries (with associated cstring pointers) in MATLAB
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
somayyah jurair
am 16 Mär. 2016
Bearbeitet: somayyah jurair
am 8 Aug. 2020
Hey i want to call library sb of external software into MATLAB. I tried unsing following:
[Status, Errormsg]=calllib(‘sb’, ‘sbdb’, Dbloc, Dbname)
But calllib function could not be executed. MATLAB is giving error msg: “No matching method found”
Please tell me how can I call functions with cstring pointers in MATLAB
Thanks & Regards,
Somayyah
3 Kommentare
Philip Borghesani
am 17 Mär. 2016
Bearbeitet: Philip Borghesani
am 17 Mär. 2016
Is SPDB here a typo or did you not give the signature for sbdb? Does SBDB show up in the libfunctions output?
Akzeptierte Antwort
Philip Borghesani
am 17 Mär. 2016
Bearbeitet: Philip Borghesani
am 17 Mär. 2016
You can only call functions that appear int the output of libfunctions -full with arguments that can be converted to those listed. If the function you want is not there then you need to debug your loadlibrary call or you need to use a different function. From your description it looks like errormsg must be an input to the function and if the signature you gave is correct then the length of the buffer probably needs to be passed too. Note that the functions appeared to matlab as upper cased. Given the documentation you supplied I would call:
[status,~,~,errmessage]=calllib('sb','SBDB', 'C:\extsoft’,’rfdb.mdb’,blanks(200));
blanks(200) produces a buffer to hold the error message. The needed length of the buffer should be documented somewhere or there should be an extra parameter to specify it. No need for libpointers at all.
2 Kommentare
Philip Borghesani
am 17 Mär. 2016
Bearbeitet: Philip Borghesani
am 17 Mär. 2016
To call the function according to the prototype you gave you will need to call:
sz=200;
[~,~,sizeout,errmessage]=calllib('sb','SBDB', 'C:\extsoft’,’rfdb.mdb’,sz, blanks(sz));
I am not sure about the use of sz it may be that it is status not size;
I believe you are mi-interpreting the documentation or something else is in error. Without more information and the header declarations there is no way to verify what is expected.
This line:
Errormsg is a pointer to buffer that will be filled with error message.
Implies that errormsg is an input parameter that will be used for output.
A basic understanding on how functions pass parameters in C is probably needed to properly utilize loadlibrary and calllib.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Call C from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!