MATLAB: Am I receiving errors when compiling matdgns.c or matcreat.c for the MATLAB Engine on a PC using the free Borland Compiler 5.5

_main_winmainapplicationborlandcompilerengineerrorfreeMATLABwinmain

The error that I am receiving is:
Error: Unresolved external 'WinMain' referenced from
C:\BORLAND\BCC55\LIB\C0W32.OBJ
C:\MATLAB6P5\BIN\WIN32\MEX.PL: Error: Link of 'matdgns.exe' failed.

Best Answer

This error is due to the fact that the bcc55freeengmatopts.bat was created with the assumption that users will only try to build graphical applications. However, since matdgns.c and matcreat.c are console based applications and only have the "main" entry point, the above linker error is generated.
You can resolve this problem by modifying line 38 of the bccfreeengmatopts.bat file which includes
set LINKFLAGS=-tWE -L"%BORLAND%"\lib\32bit -L"%BORLAND%"\lib

to
set LINKFLAGS=-tWC -L"%BORLAND%"\lib\32bit -L"%BORLAND%"\lib
Note that you will need to reverse this change if you wish to compile a graphical application.