Shared Library shrlibsample
MATLAB® includes a sample external library called shrlibsample
.
The library is in the folder
.matlabroot
\extern\examples\shrlib
View the source code in MATLAB.
edit([matlabroot '/extern/examples/shrlib/shrlibsample.c']) edit([matlabroot '/extern/examples/shrlib/shrlibsample.h'])
To use the shrlibsample
library, choose one of the
following.
Add the folder to your MATLAB path:
addpath(fullfile(matlabroot,'extern','examples','shrlib'))
Make the folder your current working folder:
cd(fullfile(matlabroot,'extern','examples','shrlib'))
Load the library and display the MATLAB signatures for the functions in the library.
loadlibrary('shrlibsample') libfunctions shrlibsample -full
Functions in library shrlibsample: [double, doublePtr] addDoubleRef(double, doublePtr, double) double addMixedTypes(int16, int32, double) [double, c_structPtr] addStructByRef(c_structPtr) double addStructFields(c_struct) c_structPtrPtr allocateStruct(c_structPtrPtr) voidPtr deallocateStruct(voidPtr) lib.pointer exportedDoubleValue lib.pointer getListOfStrings doublePtr multDoubleArray(doublePtr, int32) [lib.pointer, doublePtr] multDoubleRef(doublePtr) int16Ptr multiplyShort(int16Ptr, int32) doublePtr print2darray(doublePtr, int32) printExportedDoubleValue cstring readEnum(Enum1) [cstring, cstring] stringToUpper(cstring)