GreySage
GreySage

Reputation: 1180

Can't create a .dll from Matlab Coder

I am trying to convert some matlab code into a c dynamic library (.dll) using the Matlab Coder tool. I'm trying it on some simple sample code, but I keep getting the same error which I can't find a solution to.

My code is:

function y = lbryTest(x, z) %#codegen
%QUICKTEST Summary of this function goes here
%   Detailed explanation goes here
y = 1.0;
a = x + z;
b = x * a;
y = b/3 + y;
end

I've tried using the app version of coder as well as the command: codegen -config:dll lbryTest -args {2.0, 5.0} and the build log, including the error, is:

1   C:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/bin/lcc64 -c -w -noregistrylookup -nodeclspec -IC:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/include64 -DMODEL=lbryTest -DHAVESTDIO -DUSE_RTMODEL -IC:/Users/shutchinson/Documents/MATLAB -IC:/Users/shutchinson/Documents/MATLAB/codegen/dll/lbryTest -IC:/PROGRA~1/MATLAB/R2015a/extern/include -IC:/PROGRA~1/MATLAB/R2015a/simulink/include -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/ert -Fo"lbryTest_initialize.obj" "lbryTest_initialize.c"
2   C:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/bin/lcc64 -c -w -noregistrylookup -nodeclspec -IC:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/include64 -DMODEL=lbryTest -DHAVESTDIO -DUSE_RTMODEL -IC:/Users/shutchinson/Documents/MATLAB -IC:/Users/shutchinson/Documents/MATLAB/codegen/dll/lbryTest -IC:/PROGRA~1/MATLAB/R2015a/extern/include -IC:/PROGRA~1/MATLAB/R2015a/simulink/include -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/ert -Fo"lbryTest_terminate.obj" "lbryTest_terminate.c"
3   C:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/bin/lcc64 -c -w -noregistrylookup -nodeclspec -IC:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/include64 -DMODEL=lbryTest -DHAVESTDIO -DUSE_RTMODEL -IC:/Users/shutchinson/Documents/MATLAB -IC:/Users/shutchinson/Documents/MATLAB/codegen/dll/lbryTest -IC:/PROGRA~1/MATLAB/R2015a/extern/include -IC:/PROGRA~1/MATLAB/R2015a/simulink/include -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/ert -Fo"lbryTest.obj" "lbryTest.c"
4   C:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/bin/lcc64 -c -w -noregistrylookup -nodeclspec -IC:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/include64 -DMODEL=lbryTest -DHAVESTDIO -DUSE_RTMODEL -IC:/Users/shutchinson/Documents/MATLAB -IC:/Users/shutchinson/Documents/MATLAB/codegen/dll/lbryTest -IC:/PROGRA~1/MATLAB/R2015a/extern/include -IC:/PROGRA~1/MATLAB/R2015a/simulink/include -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/ert -Fo"rt_nonfinite.obj" "rt_nonfinite.c"
5   C:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/bin/lcc64 -c -w -noregistrylookup -nodeclspec -IC:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/include64 -DMODEL=lbryTest -DHAVESTDIO -DUSE_RTMODEL -IC:/Users/shutchinson/Documents/MATLAB -IC:/Users/shutchinson/Documents/MATLAB/codegen/dll/lbryTest -IC:/PROGRA~1/MATLAB/R2015a/extern/include -IC:/PROGRA~1/MATLAB/R2015a/simulink/include -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/ert -Fo"rtGetNaN.obj" "rtGetNaN.c"
6   C:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/bin/lcc64 -c -w -noregistrylookup -nodeclspec -IC:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/include64 -DMODEL=lbryTest -DHAVESTDIO -DUSE_RTMODEL -IC:/Users/shutchinson/Documents/MATLAB -IC:/Users/shutchinson/Documents/MATLAB/codegen/dll/lbryTest -IC:/PROGRA~1/MATLAB/R2015a/extern/include -IC:/PROGRA~1/MATLAB/R2015a/simulink/include -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2015a/rtw/c/ert -Fo"rtGetInf.obj" "rtGetInf.c"
7   C:/PROGRA~1/MATLAB/R2015a/sys/perl/win32/bin/perl.exe C:/PROGRA~1/MATLAB/R2015a/rtw/c/tools/mkvc_lnk.pl lbryTest.lnk lbryTest_initialize.obj lbryTest_terminate.obj lbryTest.obj rt_nonfinite.obj rtGetNaN.obj rtGetInf.obj lccstub.obj
8   "### Creating dynamic library "./lbryTest.dll" ..."
9   C:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/bin/lcclnk64 -dll -entry LibMain -s -LC:/PROGRA~1/MATLAB/R2015a/sys/lcc64/lcc64/lib64  lbryTest.def -o ./lbryTest.dll @lbryTest.lnk  
10   cannot open lccstub.obj
11   gmake: *** [lbryTest.dll] Error 1
12   The make command returned an error of 2
13   'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
14   operable program or batch file.
15   
16   Error(s) encountered while building model "lbryTest":
17   ### Failed to generate all binary outputs.

I can make a .lib from this code, but I need a .dll, which is proving difficult. It looks like I am missing some object file or matlab can't find it, but I don't know what to do about it.

Upvotes: 0

Views: 749

Answers (1)

GreySage
GreySage

Reputation: 1180

credit to Ryan Livingston for this suggestion, which I am turning into an official answer

The file lccstub.c (compiled to lccstub.obj) isn't on your machine, when it should be. To fix it, you should install a supported compiler for Matlab.

Windows SDK 7.1 is available for free from here

Upvotes: 1

Related Questions