Mex entry point missing (despite correct entry)

2 次查看(过去 30 天)
I'm getting the mex entry point missing error with a compiled cpp program. Here's the cpp:
#include "stdafx.h"
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
plhs[0] = mxCreateString("hello world");
}
The entry function name and arguments seem fine to me, unless I'm missing something. It compiles fine using visual studio 2015 and VC++ compiler. What could be causing this?
Thanks in advance
edit:
When I compile it within visual studio, I get the entry mex file missing. When I compile it using 'mex' in matlab 2015b (using the same compiler as used in visual studio) it works. Given that it is the same compiler, what could be the difference?
edit 2:
Figured it out eventually. I didn't create the .def file that I guess is necessary. Right click on your project, go to add, select code and .def file. Fill out the file as shown in:
except replace MYFILE with the name of the output file, including the extension. Something like:
LIBRARY "MyProgram.mexw64" EXPORTS mexFunction

回答(1 个)

James Tursa
James Tursa 2016-3-12
Do the mex compile at the command line with the verbose option, then look at how it is being compiled and everything that is getting linked in and compare that with what you are doing.
  1 个评论
Chris Wolf
Chris Wolf 2016-3-13
I did that, and noticed I wasn't linking to all the libraries that matlab is linking to in visual studio. I made the change, but I'm still getting the behavior.
I checked all the include directories, library directories, and libraries. They all match now. Visual studio is compiling to a .dll with the correct output extension, with 64-bit platform selected.
What else should I be looking for in the verbose output? Its a lot of gibberish to me...
thanks for your help so far. I'm at least able to do the compiling in matlab, but it would be much better if I could stick with visual studio for the entire process, as it makes source version control a lot easier.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by