0

I have some matlab code (split over 4 files test.m, a.m, b.m, c.m) from which I'd like to generate DLL file to be called by external application. The main function test(x, y, z) in test.m contains three inputs of type string without any output argument - it writes some data into a file.

I'm generating the from matlab DLL with:

mcc -B csharedlib:testLib test.m a.m b.m c.m

I'm receiving some files and DLL.

Now I'm calling this DLL by following python code:

from ctypes import *

mydll = cdll.LoadLibrary("testLib.dll")
mydll.test("string1", "string2", "string3")

On the 2nd line I'm getting following error: "OSError: [WinError 193] %1 is not a valid Win32 application"

Any idea where there is a problem?

P.S. don't ask why I'm using this version of Matlab (I'd prefer to use a newer one).

2
  • Check this post. And read MATLAB documentation. Executing mydll.testLibInitialize() and mydll.testLibTerminate() works fine, but passing strings ??? Check this post. Commented Jan 9, 2020 at 23:13
  • I am using newer MATLAB version, use Dependency Walker for checking the DLL interface functions. Make sure you are not mixing x86 and x64 architectures... Commented Jan 9, 2020 at 23:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.