MATLAB Answers

Compiling error with Matlab 2019b - Error using mbuild (line 166)

8 views (last 30 days)
Kristoffer Lied
Kristoffer Lied on 3 Dec 2019
Answered: Sunil Patidar on 9 Mar 2021
I’m having some issues when I try to compile a DLL in Matlab 2019b. I use the Library Compiler to create a DLL of a Matlab function, and then I create a wrapper and DLL using the mbuild command. I have recently been using Matlab 2014a, and I can use the following line without issue to create the DLL and wrappercode:
mbuild -v -g wtest.c test.lib LINKFLAGS="$LINKFLAGS /DLL " LDEXT=".dll" CMDLINE250="mt -outputresource:$EXE';'2 -manifest $MANIFEST";
However, if I use the same code in Matlab 2019b (I have compiled the Matlab function with the 2019b Library Compiler), I get the following error:
Error using mbuild (line 166)
Unable to complete successfully.
undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
In Matlab 2014a the DLL is built using 'Microsoft Windows SDK 7.1', while the Matlab 2019b uses 'MinGW64 Compiler'.
I’ve had some troubles installing MinGW64 extension as I have Matlab on an offline computer, and I suspect this could be some of the issue. I've tried to reinstall it and still have the same issue.
Do you have any advice?
Kristoffer Lied
Kristoffer Lied on 3 Apr 2020
Hello! Sorry for the late reply.
No, I have not resolved the problem.

Sign in to comment.

Answers (1)

Sunil Patidar
Sunil Patidar on 9 Mar 2021
Try using any of the supported Microsoft Visual C compiler mentioned in the list in the link below and see if you are able to generate the DLL wrapper
Once you have installed the compiler you can use the "mbuild -setup" command to change the compiler that MATLAB will use.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!