All the files(header or dll or any other files) that are needed by a ".m" file to run can be compiled along with the ".m" file by using -a flag in mcc command.
>> mcc –m foo.m [-a filename...]
You can learn more about the usage of -a flag by executing the following command in MATLAB:
>> docsearch mcc -a
You cannot copy/paste .h file into for_testing folder, because when the compiled application runs it needs to know the location of the header file in memory. Deployable MATLAB files are suspended or frozen at the time MATLAB Compiler encrypts them—they do not change from that point onward. When the application is compiled without the header file, there is no way for the application to determine the physical location of header file in memory.