Filter löschen
Filter löschen

How to write/edit prototype file when .h and .dll files dont work correctly?

2 Ansichten (letzte 30 Tage)
Hi, I am trying to control a Keyence LJ-V7000 series profilometer with Matlab. Keyence provide .dll and .h files (32 bit) to control the unit however I am unable to get the library to load correctly. I downgraded to 2015b (32 bit) matlab in order to run the dll however hundreds of warnings appear. Obviously this relates to the data types as all the warnings read;
"Warning: The data type 'error#4' used by structure LJV7IF_ETHERNET_CONFIG does not exist. The structure may not be usable."
I created a prototype file to save editing the header file, however I am unsure of the proper form the protofile should have? Much of the code looks like this;
fcns.name{fcnNum}='LJV7IF_Initialize'; fcns.calltype{fcnNum}='stdcall'; fcns.LHS{fcnNum}='error'; fcns.RHS{fcnNum}=[];fcnNum=fcnNum+1;
structs.LJV7IF_ETHERNET_CONFIG.members=struct('abyIpAddress', 'error#4', 'wPortNo', 'error', 'reserve', 'error#2');
structs.LJV7IF_TARGET_SETTING.members=struct('byType', 'error', 'byCategory', 'error', 'byItem', 'error', 'reserve', 'error', 'byTarget1', 'error', 'byTarget2', 'error', 'byTarget3', 'error', 'byTarget4', 'error');
I have attached the prototype file, but cannot attach the .dll and .h file.
I would greatly appreciate any help/guidance on how the protofile should look as this is my first attempt into this side of matlab.
Thank you,
Michael

Antworten (1)

Philip Borghesani
Philip Borghesani am 14 Nov. 2016
Bearbeitet: Philip Borghesani am 14 Nov. 2016
I would start by trying to fix the header file to get a better prototype file to start with. This header appears to be only compatible with C++ even though it may define a c compatible library because the extern "C" statement is not protected by an #ifdef __cplusplus block.
The header also appears to need an #include &lt windows.h &gt statement to compile correctly. You can cadd the include statement to the beginning of the header or created a new header that includes both headers and use the addheader option to loadlibrary to add functions from the vendors header. Once those problems are fixed you may discover others.
If there are no examples for calling this library from c or other languages then you may be better off creating a c++ mex file to call this library then attempting to load it with loadlibrary.

Kategorien

Mehr zu Write C Functions Callable from MATLAB (MEX Files) 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!

Translated by