MATLAB: How to generate MATLAB Coder code that does not use tbb libraries

codegendependencymatlab coderparalleltbbthreading

I'm using MATLAB coder for generating C++ code. I see that MATLAB uses several libraries (dlls and libs) like:
libmwmorphop_binary_tbb.lib
libmwbwlookup_tbb.lib
Which is any library in the following format: libmw*_tbb.lib or libmw*_tbb.dll.
Due to an overall system performance, I'd like to generate code that does not_* *_depend on the "tbb" libraries.

Best Answer

tbb libraries, or "thread build blocks", are used for parallel programming. In this case to disable dependency for these libraries, you can launch MATLAB with the startup flag -singleCompThread
(<https://www.mathworks.com/help/matlab/ref/matlabwindows.html#buklxlz-3>)
After doing so, verify that you're in single thread mode at the MATLAB command line:
>> maxNumCompThreads
ans =
1
Once you've done this, you can proceed with your normal MATLAB Coder workflow (e.g. the MATLAB Coder App or using the "codegen" function at the command line). Then, use the "packNGo" function to zip up the generated code and dependencies. In single thread mode, you will no longer see dependencies on "tbb" libraries. See below for an example where single thread mode has no "tbb" dependency: