I have complied DLL that I am able to use in a C++, and I would like to use it in MATLAB.
The C++ code utilizes GetProcAddress to access a structure that is exported by the library:
structPointer = (ext_struct*)GetProcAddress(myDLL, "exportedStructure");
Which we must later write some data to:
fscanf(input_data, "%d", &structPointer->a);
In MATLAB I am able to successfully load the library and can see the functions in the library using
loadlibrary(myDLL)libfunctions(myDLL)
I would like an equivalent to the GetProcAddress which would allow me to access the member variable.
Best Answer
You can use the 'calllib' function to access exported variables in a shared library.
For example, if I have the following structure and exported variable in my library header file:
And the c_struct variable 'exportedStruct' is defined in my library as:
Then I can access this structure from MATLAB as follows:
This will return a 'lib.pointer' object pointing to the variable, which you can then use to interact with the variable: