I'm trying to run the matlabdemo.c provided with most copies of matlab (mine being Matlab R2007b) and despite my best efforts I keep getting "unresolved externals" errors when I try to compile the program via the Visual Studio Command Prompt.
I compiled with: "cl -I"C:\Program Files\MATLAB\R2007b\extern\include" matlabdemo.c -link -dll -LIBPATH:"../lib/win64/microsoft/"labeng.lib"
Thanks in advance!
Here's a sample batch script to compile the engdemo.c
program.
Obviously you have to adjust the paths to point to your MATLAB installation (also choose 32/64 bit versions correctly)
call vcvarsall.bat
set MATLABROOT=C:\Program Files\MATLAB\R2012a
cl.exe engdemo.c libeng.lib libmx.lib /Fe"engdemo" /I"%MATLABROOT%\extern\include" /link /libpath:"%MATLABROOT%\extern\lib\win32\microsoft"
You might need to put the MATLAB bin
directory on the path when you run it:
set PATH=%MATLABROOT%\bin\win32;%PATH%