MATLAB: Can’t I compile tcpclient in MATLAB R2018a

MATLAB Compilermatlab:networklib:tcpclient:cannotcreateobjectmatlabshared.transportlib.internal.itransportr2018atcpclient

I have a very simple code that works fine in MATLAB R2018a but not in a compiled application.
t = tcpclient('www.mathworks.com', 80)
It seems like function 'tcpclient' cannot be compiled using MATLAB Compiler R2018a.
When run the executable after compiling, the following error is thrown-
"The specified superclass 'matlabshared.transportlib.internal.ITransport' contains a parse error, cannot be found on MATLAB's search path, or is shadowed by another file with the same name.
MATLAB:networklib:tcpclient:cannotCreateObject "
The same code works fine in until R2017b in both MATLAB and compiled environments.
How can I make it work in R2018a?

Best Answer

There is a problem in R2018a MATLAB Compiler as it does not detect the files required to compile 'tcpclient'.
This will be fixed in future releases.
A workaround for this issue would be to add transportlib folder in mcc command manually by -a flag.
Assuming the file name is test1.m and you have installed MATLAB on default location, the command you may need to run is-
>> mcc -m test1.m -a 'C:\Program Files\MATLAB\R2018a\toolbox\shared\transportlib'
If you are compiling this using deploytool UI, please add the following statement to the additional parameters passed to MCC under settings in deploytool UI-
-a 'C:\Program Files\MATLAB\R2018a\toolbox\shared\transportlib'