Main Content

Call Functions in Linux Interface to C++ Compiled Library

Set MATLAB Path to Interface and Library Folder

If you created the matrixOperations interface in the example Header and C++ Compiled Library Files on Linux, then you can use it in this example. Navigate to the folder you used to create the matrixOperations interface file.

Put the compiled library file in the folder with the MATLAB® interface file.

copyfile(fullfile(productPath,"glnxa64","*.so"),".","f")

Call addpath on the folder containing the interface file.

View Help

At the MATLAB command prompt, display help for the interface. In the example, the clibgen.generateLibraryDefinition command set the name of the interface to matrixlib. Type this command to load the interface.

doc clib.matrixlib.Mat

To display the members of clib.matrixlib, type:

doc clib.matrixlib
Classes contained in clib.matrixlib:
Mat             - clib.matrixlib.Mat    Representation of C++ class Mat

Functions contained in clib.matrixlib:
addMat          - clib.matrixlib.addMat    Representation of C++ function addMat
updateMatByX    - clib.matrixlib.updateMatByX    Representation of C++ function updateMatByX
updateMatBySize - clib.matrixlib.updateMatBySize    Representation of C++ function updateMatBySize

To display signatures for the functions, click the links for addMat, updateMatByX, and updateMatBySize.

clib.matrixlib.addMat    Representation of C++ function addMat
  Input Arguments
    mat            read-only clib.matrixlib.Mat
  Output Arguments
    RetVal         int32

clib.matrixlib.updateMatByX    Representation of C++ function updateMatByX
  Input Arguments
    mat            clib.matrixlib.Mat
    X              int32
  Output Arguments

clib.matrixlib.updateMatBySize    Representation of C++ function updateMatBySize
  Input Arguments
    mat            clib.matrixlib.Mat
    arr            int32
  Output Arguments

To display information about class clib.matrixlib.Mat, click the link for Mat.

clib.matrixlib.Mat    Representation of C++ class Mat
Method Summary:
  Mat                 - clib.matrixlib.Mat    Constructor of C++ class Mat
  Mat                 - clib.matrixlib.Mat    Constructor of C++ class Mat
  setMat              - clib.matrixlib.Mat.setMat    Method of C++ class Mat
  getMat              - clib.matrixlib.Mat.getMat    Method of C++ class Mat
  getLength           - clib.matrixlib.Mat.getLength    Method of C++ class Mat
  copyMat             - clib.matrixlib.Mat.copyMat    Method of C++ class Mat

To display constructor and method signatures, use the methods or methodsview functions. For example, type:

methodsview clib.matrixlib.Mat

Call Library Functions

Test the functions in the interface. For example, type:

matObj = clib.matrixlib.Mat;   % Create a Mat object
intArr = [1,2,3,4,5];
matObj.setMat(intArr);     % Set the values to intArr
retMat = matObj.getMat(5)  % Display the values
retMat =

  1×5 int32 row vector

   1   2   3   4   5

Related Topics