Why my function are not available after compiling the dll on matlab?

51 views Asked by At

Function not found after compilation of a shared library on matlab

I want to use a c# program to call matlab to execute complex functions, display plots, and do algorithms.

In this goal, I start with the base, to generate matlab functions for simple things. I want to have a list of functions on matlab that are callable via my c sharp code.

What I do:

in a utils.m file:

function ports = getPortComs()
    ports = seriallist();
end

Following that i use mcc -W 'dotnet:MatlabLib,MatlabClass' -T link:lib utils.m to generate dll file.

On Visual Studio 2022, i add reference to this dll.

My C# code :

using MatlabLib;

namespace XXX
{


    public partial class Form1 : Form {


        public Form1()
        {
            InitializeComponent();

            MatlabClass matlab = new MatlabClass();

            string[] ports = matlab.getPortComs(); //HERE : Not found
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            //Not used yet
        
        }

        
    }
}

On comment //HERE : Not found, i can't found this function. Error is : "Error CS1061 'MatlabClass' contains no definition for 'getPortComs' and no extension method "

Do you have any idea where the problem lies or any suggestions for me?

0

There are 0 answers