MATLAB: Do I receive the LNK2001 error when trying to compile a simple MATLAB program using MATLAB Compiler 4.8 (R2008b)

11202001compilinglnkMATLAB Compiler

I have a simple MATLAB file and when I try to compile this file I receive the following error:
<SNIP>
myfile_main.obj : error LNK2001: unresolved external symbol _mclInitializeComponentInstanceWithEmbeddedCTF_proxy
myfile_main.obj: error LNK2001: unresolved external symbol _mclmcrInitialize_proxy
myfile_main.obj: error LNK2001: unresolved external symbol _mclWrite_proxy
myfile_main.obj: error LNK2001: unresolved external symbol _mclTerminateInstance_proxy
myfile_main.obj: error LNK2001: unresolved external symbol _mclTerminateApplication_proxy
myfile_main.obj: error LNK2001: unresolved external symbol _mclWaitForFiguresToDie_proxy
myfile_main.obj: error LNK2001: unresolved external symbol _mclMain_proxy
myfile_main.obj: error LNK2001: unresolved external symbol _separatePathName_proxy
myfile_main.obj: error LNK2001: unresolved external symbol _mclRunMain_proxy
myfile_main.obj: error LNK2001: unresolved external symbol _mclInitializeApplication_proxy
myfile.exe : fatal error LNK1120: 10 unresolved externals
C:\MATLAB\R2008A\BIN\MEX.PL: Error: Link of 'myfile.exe' failed.
Error: An error occurred while shelling out to mbuild (error code = 2).
Unable to build executable.
??? Error using ==> mcc
Error executing mcc, return status = 1.

Best Answer

The LNK2001 error message indicates that the compiler is trying to link against the incorrect version of “mclmcrrt.lib” file.
For example, if the selected compiler is LCC and there exists a copy of the “mclmcrrt.lib” file belonging to some other compiler in the current working directory, then the LNK2001 error will occur due to conflicting compiler symbols.
Verify whether there exists a “mclmcrrt.lib” file in the current directory. If so, you can remove the file since it is not necessary to have this file in the current working directory. The MATLAB Compiler will automatically pick up the correct “mclmcrrt.lib” file depending on the selected compiler during compile time.