I'm using Visual Studio 2012 x64 to build and debug a MATLAB 2014a x64 mex file directly (without using the mex
command in MATLAB). I followed the instructions in this question to set up a Visual Studio project named test1
. I followed this tutorial to write a simple mex file, test1.cpp
:
#include <math.h>
#include <matrix.h>
#include <mex.h>
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mexPrintf("Hello World!\n");
}
Building this solution gives me this message:
> 1>------ Build started: Project: test1, Configuration: Debug Win32
> ------ 1> Creating library C:\PROJECTS\matlab\mex\test1\Debug\test1.lib
> and object
> C:\PROJECTS\matlab\mex\test1\Debug\test1.exp
> 1>test1.obj : error LNK2019: unresolved external symbol _mexPrintf
> referenced in function _mexFunction 1>MSVCRTD.lib(crtexe.obj) : error
> LNK2019: unresolved external symbol _main referenced in function
> ___tmainCRTStartup 1>C:\PROJECTS\matlab\mex\test1\Debug\test1.mexw64
> : fatal error LNK1120: 2 unresolved externals
> ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Are there configuration steps I'm missing here? I used the steps in this answer exactly, but maybe it's incomplete for more recent versions of MATLAB?