共享库 shrlibsample
MATLAB® 包含名为 shrlibsample
的示例外部库。该库位于
文件夹中。matlabroot
\extern\examples\shrlib
在 MATLAB 中查看源代码。
edit([matlabroot '/extern/examples/shrlib/shrlibsample.c']) edit([matlabroot '/extern/examples/shrlib/shrlibsample.h'])
要使用 shrlibsample
库,请选择以下项之一。
将文件夹添加到您的 MATLAB 路径中:
addpath(fullfile(matlabroot,'extern','examples','shrlib'))
将该文件夹设为当前工作文件夹:
cd(fullfile(matlabroot,'extern','examples','shrlib'))
加载库并显示库中函数的 MATLAB 签名。
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)